aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-28 02:58:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-28 02:58:12 +0000
commitce2eb5f09671ca7e7f19ea5826e7bed19df78321 (patch)
treef175c961aa3bf59e529b03a0e51f457626d90609 /numeric.c
parente66e01381ed4081bd8b38a5d328d0e9c5a20c963 (diff)
downloadruby-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 'numeric.c')
-rw-r--r--numeric.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index a8b932a4c6..8c52630ce0 100644
--- a/numeric.c
+++ b/numeric.c
@@ -5140,7 +5140,7 @@ prefix##_isqrt(argtype n) \
while ((t = n/x) < (argtype)x) x = (rettype)((x + t) >> 1); \
return x; \
} \
- return (rettype)sqrt((double)n); \
+ return (rettype)sqrt(argtype##_TO_DOUBLE(n)); \
}
#if SIZEOF_LONG*CHAR_BIT > DBL_MANT_DIG
@@ -5148,6 +5148,7 @@ prefix##_isqrt(argtype n) \
#else
# define RB_ULONG_IN_DOUBLE_P(n) 1
#endif
+#define RB_ULONG_TO_DOUBLE(n) (double)(n)
#define RB_ULONG unsigned long
DEFINE_INT_SQRT(unsigned long, rb_ulong, RB_ULONG)
@@ -5157,6 +5158,11 @@ DEFINE_INT_SQRT(unsigned long, rb_ulong, RB_ULONG)
# else
# define BDIGIT_DBL_IN_DOUBLE_P(n) 1
# endif
+# ifdef ULL_TO_DOUBLE
+# define BDIGIT_DBL_TO_DOUBLE(n) ULL_TO_DOUBLE(n)
+# else
+# define BDIGIT_DBL_TO_DOUBLE(n) (double)(n)
+# endif
DEFINE_INT_SQRT(BDIGIT, rb_bdigit_dbl, BDIGIT_DBL)
#endif