From d6ec0ef59b4c7c95beaad09f77cb5f86a0901b97 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 15 Apr 2020 00:52:08 +0900 Subject: Added `get_real` interface --- ext/-test-/random/loop.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ext/-test-/random') diff --git a/ext/-test-/random/loop.c b/ext/-test-/random/loop.c index 92af1a9b18..246a1f5fd9 100644 --- a/ext/-test-/random/loop.c +++ b/ext/-test-/random/loop.c @@ -7,10 +7,13 @@ typedef struct { uint32_t num, idx, *buf; } rand_loop_t; +static double loop_get_real(rb_random_t *rnd, int excl); + RB_RANDOM_INTERFACE_DECLARE(loop) static const rb_random_interface_t random_loop_if = { 32, RB_RANDOM_INTERFACE_DEFINE(loop) + loop_get_real, }; static size_t @@ -91,6 +94,13 @@ loop_get_int32(rb_random_t *rnd) return 0; } +static double +loop_get_real(rb_random_t *rnd, int excl) +{ + uint32_t a = loop_get_int32(rnd); + return ldexp(a, -16); +} + void Init_random_loop(VALUE mod, VALUE base) { -- cgit v1.2.3