mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
12b2e16e21
commit
3a4c2bc034
2 changed files with 22 additions and 19 deletions
|
@ -1,3 +1,7 @@
|
|||
Thu Apr 1 14:07:51 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* util.c (BSD__hdtoa): don't use C99 macros. (FP_NORMAL etc)
|
||||
|
||||
Thu Apr 1 13:30:12 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* sprintf.c (rb_str_format): support %a format. [ruby-dev:40650]
|
||||
|
|
37
util.c
37
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;
|
||||
|
|
Loading…
Reference in a new issue