1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Added rb_int_pair_to_real

This commit is contained in:
Nobuyoshi Nakada 2020-04-15 00:45:38 +09:00
parent af5e87ab21
commit c449b9b02f
Notes: git 2020-09-07 20:08:35 +09:00
2 changed files with 7 additions and 2 deletions

View file

@ -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;

View file

@ -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);
}