diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-28 02:58:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-28 02:58:12 +0000 |
commit | ce2eb5f09671ca7e7f19ea5826e7bed19df78321 (patch) | |
tree | f175c961aa3bf59e529b03a0e51f457626d90609 /bignum.c | |
parent | e66e01381ed4081bd8b38a5d328d0e9c5a20c963 (diff) | |
download | ruby-ce2eb5f09671ca7e7f19ea5826e7bed19df78321.tar.gz |
Makefile.sub: ULL_TO_DOUBLE
* win32/Makefile.sub (config.h): define ULL_TO_DOUBLE for
conversion from unsigned __int64 to double, which is not
implemented in till Visual Studio.NET 2003, aka VC7.1.
* bignum.c (estimate_initial_sqrt): use ULL_TO_DOUBLE if defined.
* numeric.c (BDIGIT_DBL_TO_DOUBLE): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -6765,9 +6765,15 @@ rb_big_even_p(VALUE num) unsigned long rb_ulong_isqrt(unsigned long); #if SIZEOF_BDIGIT*2 > SIZEOF_LONG BDIGIT rb_bdigit_dbl_isqrt(BDIGIT_DBL); +# ifdef ULL_TO_DOUBLE +# define BDIGIT_DBL_TO_DOUBLE(n) ULL_TO_DOUBLE(n) +# endif #else # define rb_bdigit_dbl_isqrt(x) (BDIGIT)rb_ulong_isqrt(x) #endif +#ifndef BDIGIT_DBL_TO_DOUBLE +# define BDIGIT_DBL_TO_DOUBLE(n) (double)(n) +#endif static BDIGIT * estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len) @@ -6789,9 +6795,9 @@ estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len) d <<= -rshift; d |= nds[len-dbl_per_bdig-1] >> (BITSPERDIG+rshift); } - f = sqrt((double)d); + f = sqrt(BDIGIT_DBL_TO_DOUBLE(d)); d = (BDIGIT_DBL)ceil(f); - if ((double)d == f) { + if (BDIGIT_DBL_TO_DOUBLE(d) == f) { if (lowbits || (lowbits = !bary_zero_p(nds, len-dbl_per_bdig))) ++d; } |