summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-28 02:58:12 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-28 02:58:12 (GMT)
commit7def0928040f29a3496b5e5b7c64a95b8b2ff8ad (patch)
treef175c961aa3bf59e529b03a0e51f457626d90609 /numeric.c
parent0e099878ebe34e2086d3a22432f6ccc327e9b358 (diff)
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 a8b932a..8c52630 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