* random.c (int_pair_to_real_inclusive): Use rb_integer_pack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
479b17ed12
commit
8ca1e1238e
@ -1,3 +1,7 @@
|
|||||||
|
Sat Jun 8 11:17:39 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* random.c (int_pair_to_real_inclusive): Use rb_integer_pack.
|
||||||
|
|
||||||
Sat Jun 8 09:49:42 2013 Tanaka Akira <akr@fsij.org>
|
Sat Jun 8 09:49:42 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* random.c (int_pair_to_real_inclusive): Use rb_integer_unpack.
|
* random.c (int_pair_to_real_inclusive): Use rb_integer_unpack.
|
||||||
|
20
random.c
20
random.c
@ -302,21 +302,11 @@ int_pair_to_real_inclusive(uint32_t a, uint32_t b)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if 64 % BITSPERDIG == 0
|
uint32_t uary[4];
|
||||||
long len = RBIGNUM_LEN(x);
|
rb_integer_pack(x, NULL, NULL, uary, numberof(uary), sizeof(uint32_t), 0,
|
||||||
BDIGIT *xd = BDIGITS(x);
|
INTEGER_PACK_MSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
|
||||||
MEMMOVE(xd, xd + 64 / BITSPERDIG, BDIGIT, len - 64 / BITSPERDIG);
|
/* r = x >> 64 */
|
||||||
MEMZERO(xd + len - 64 / BITSPERDIG, BDIGIT, 64 / BITSPERDIG);
|
r = (double)uary[0] * (0x10000 * (double)0x10000) + (double)uary[1];
|
||||||
r = rb_big2dbl(x);
|
|
||||||
#else
|
|
||||||
x = rb_big_rshift(x, INT2FIX(64));
|
|
||||||
if (FIXNUM_P(x)) {
|
|
||||||
r = (double)FIX2ULONG(x);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
r = rb_big2dbl(x);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return ldexp(r, -53);
|
return ldexp(r, -53);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user