summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 05:09:10 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 05:09:10 (GMT)
commit3a4c2bc034a4205ac7116c69ee39de02defb6d17 (patch)
treee7af33bc5c7b65388994f4a645215964c7ed8e64 /util.c
parent12b2e16e21bbd7f0b6fd12c7e21cba4d42e284ad (diff)
* util.c (BSD__hdtoa): don't use C99 macros. (FP_NORMAL etc)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r--util.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/util.c b/util.c
index 88914be..838f2e5 100644
--- a/util.c
+++ b/util.c
@@ -3937,26 +3937,25 @@ BSD__hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign,
else
*sign = 0;
- switch (fpclassify(d)) {
- case FP_NORMAL:
- *decpt = dexp_get(u) - DBL_ADJ;
- break;
- case FP_ZERO:
- *decpt = 1;
- return (nrv_alloc("0", rve, 1));
- case FP_SUBNORMAL:
- u.d *= 5.363123171977039e+154 /* 0x1p514 */;
- *decpt = dexp_get(u) - (514 + DBL_ADJ);
- break;
- case FP_INFINITE:
- *decpt = INT_MAX;
- return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1));
- default: /* FP_NAN or unrecognized */
- *decpt = INT_MAX;
- return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1));
+ if (isinf(d)) { /* FP_INFINITE */
+ *decpt = INT_MAX;
+ return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1));
+ }
+ else if (isnan(d)) { /* FP_NAN */
+ *decpt = INT_MAX;
+ return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1));
+ }
+ else if (d == 0.0) { /* FP_ZERO */
+ *decpt = 1;
+ return (nrv_alloc("0", rve, 1));
+ }
+ else if (dexp_get(u)) { /* FP_NORMAL */
+ *decpt = dexp_get(u) - DBL_ADJ;
+ }
+ else { /* FP_SUBNORMAL */
+ u.d *= 5.363123171977039e+154 /* 0x1p514 */;
+ *decpt = dexp_get(u) - (514 + DBL_ADJ);
}
-
- /* FP_NORMAL or FP_SUBNORMAL */
if (ndigits == 0) /* dtoa() compatibility */
ndigits = 1;