summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/bigdecimal.c
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-03 07:47:00 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-03 07:47:00 +0000
commit1c3e07f0d6d237222192f41c84716c15731b3158 (patch)
treeb207b1f80d418c4b57eec8a213d83e4069d95406 /ext/bigdecimal/bigdecimal.c
parent59cad45f9963b359b16c1b9a9324b78e5e0873d5 (diff)
* ext/bigdecimal/bigdecimal.c (Init_bigdecimal): add two new constants BigDecimal::INFINITY and BigDecimal::NAN.
* ext/bigdecimal/lib/bigdecimal/math.rb (BigMath.exp): modify the behaviors for infinity arguments as same as Math.exp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r--ext/bigdecimal/bigdecimal.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 817fc13..340ea8b 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -1902,6 +1902,8 @@ BigDecimal_sign(VALUE self)
void
Init_bigdecimal(void)
{
+ VALUE arg;
+
/* Initialize VP routines */
VpInit((U_LONG)0);
@@ -2023,6 +2025,12 @@ Init_bigdecimal(void)
/* -3: Indicates that a value is negative and infinite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE",INT2FIX(VP_SIGN_NEGATIVE_INFINITE));
+ arg = rb_str_new2("+Infinity");
+ rb_define_const(rb_cBigDecimal, "INFINITY", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
+ arg = rb_str_new2("NaN");
+ rb_define_const(rb_cBigDecimal, "NAN", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
+
+
/* instance methods */
rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);