summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-15 00:45:38 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-07 20:08:01 +0900
commitc449b9b02f63cf8268a0eb9639a43caf4598996d (patch)
tree6765aba80338204e06f753fdf1c039b9f3691d25
parentaf5e87ab218c5f4e34c6cdb54ae119a7f0f9033f (diff)
downloadruby-c449b9b02f63cf8268a0eb9639a43caf4598996d.tar.gz
Added rb_int_pair_to_real
-rw-r--r--include/ruby/random.h3
-rw-r--r--random.c6
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;
diff --git a/random.c b/random.c
index 08c69182fb..3fef5cea3b 100644
--- a/random.c
+++ b/random.c
@@ -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);
}