summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-19 01:45:36 (GMT)
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-19 01:45:36 (GMT)
commit3ca0948f68d1055cd980992dcb68deced0f4d704 (patch)
tree961c2602e81c6dc5f73e46a3a2d61565c4da16d8 /math.c
parent09b4d6e8cd50dca07997d40b7e04d6652a9a4d43 (diff)
INFINITY is float. That of double is HUGE_VAL.
It seems HUGE_VAL is already used. Why not eliminate INTINITY. NAN is also float. That of double is called nan(). This is also fixed. Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/math.c b/math.c
index ce49879..65a8056 100644
--- a/math.c
+++ b/math.c
@@ -382,8 +382,8 @@ math_atanh(VALUE unused_obj, VALUE x)
/* check for domain error */
if (d < -1.0 || +1.0 < d) domain_error("atanh");
/* check for pole error */
- if (d == -1.0) return DBL2NUM(-INFINITY);
- if (d == +1.0) return DBL2NUM(+INFINITY);
+ if (d == -1.0) return DBL2NUM(-HUGE_VAL);
+ if (d == +1.0) return DBL2NUM(+HUGE_VAL);
return DBL2NUM(atanh(d));
}
@@ -488,7 +488,7 @@ math_log1(VALUE x)
/* check for domain error */
if (d < 0.0) domain_error("log");
/* check for pole error */
- if (d == 0.0) return -INFINITY;
+ if (d == 0.0) return -HUGE_VAL;
return log(d) + numbits * M_LN2; /* log(d * 2 ** numbits) */
}
@@ -531,7 +531,7 @@ math_log2(VALUE unused_obj, VALUE x)
/* check for domain error */
if (d < 0.0) domain_error("log2");
/* check for pole error */
- if (d == 0.0) return DBL2NUM(-INFINITY);
+ if (d == 0.0) return DBL2NUM(-HUGE_VAL);
return DBL2NUM(log2(d) + numbits); /* log2(d * 2 ** numbits) */
}
@@ -561,7 +561,7 @@ math_log10(VALUE unused_obj, VALUE x)
/* check for domain error */
if (d < 0.0) domain_error("log10");
/* check for pole error */
- if (d == 0.0) return DBL2NUM(-INFINITY);
+ if (d == 0.0) return DBL2NUM(-HUGE_VAL);
return DBL2NUM(log10(d) + numbits * log10(2)); /* log10(d * 2 ** numbits) */
}
@@ -855,10 +855,10 @@ math_gamma(VALUE unused_obj, VALUE x)
/* check for domain error */
if (isinf(d)) {
if (signbit(d)) domain_error("gamma");
- return DBL2NUM(INFINITY);
+ return DBL2NUM(HUGE_VAL);
}
if (d == 0.0) {
- return signbit(d) ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY);
+ return signbit(d) ? DBL2NUM(-HUGE_VAL) : DBL2NUM(HUGE_VAL);
}
if (d == floor(d)) {
if (d < 0.0) domain_error("gamma");
@@ -893,11 +893,11 @@ math_lgamma(VALUE unused_obj, VALUE x)
/* check for domain error */
if (isinf(d)) {
if (signbit(d)) domain_error("lgamma");
- return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1));
+ return rb_assoc_new(DBL2NUM(HUGE_VAL), INT2FIX(1));
}
if (d == 0.0) {
VALUE vsign = signbit(d) ? INT2FIX(-1) : INT2FIX(+1);
- return rb_assoc_new(DBL2NUM(INFINITY), vsign);
+ return rb_assoc_new(DBL2NUM(HUGE_VAL), vsign);
}
v = DBL2NUM(lgamma_r(d, &sign));
return rb_assoc_new(v, INT2FIX(sign));