diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-15 00:45:38 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-09-07 20:08:01 +0900 |
commit | c449b9b02f63cf8268a0eb9639a43caf4598996d (patch) | |
tree | 6765aba80338204e06f753fdf1c039b9f3691d25 | |
parent | af5e87ab218c5f4e34c6cdb54ae119a7f0f9033f (diff) | |
download | ruby-c449b9b02f63cf8268a0eb9639a43caf4598996d.tar.gz |
Added rb_int_pair_to_real
-rw-r--r-- | include/ruby/random.h | 3 | ||||
-rw-r--r-- | random.c | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/include/ruby/random.h b/include/ruby/random.h index bb6cf73bae..21b6796a3e 100644 --- a/include/ruby/random.h +++ b/include/ruby/random.h @@ -63,8 +63,7 @@ typedef const rb_data_type_t rb_random_data_type_t; #endif void rb_random_mark(void *ptr); -double rb_int_pair_to_real_exclusive(uint32_t a, uint32_t b); -double rb_int_pair_to_real_inclusive(uint32_t a, uint32_t b); +double rb_int_pair_to_real(uint32_t a, uint32_t b, int excl); void rb_rand_bytes_int32(rb_random_get_int32_func *, rb_random_t *, void *, size_t); RUBY_EXTERN const rb_data_type_t rb_random_data_type; @@ -992,6 +992,12 @@ random_real(VALUE obj, rb_random_t *rnd, int excl) a = random_int32(rng, rnd); b = random_int32(rng, rnd); } + return rb_int_pair_to_real(a, b, excl); +} + +double +rb_int_pair_to_real(uint32_t a, uint32_t b, int excl) +{ if (excl) { return int_pair_to_real_exclusive(a, b); } |