summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/bigdecimal.c
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-07 01:58:59 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-07 01:58:59 +0000
commit3a5daefe1f3e7b55571febe2e50d736fa7bed82e (patch)
tree1355b44543176c3c75d69bfd93d6e509c78ef0ee /ext/bigdecimal/bigdecimal.c
parent12e7e79727527175572f74b144a331d288d620c2 (diff)
* ext/bigdecimal/bigdecimal.c: Document +@, -@, hash, INFINITY, Nan.
Patch by Sylvain Daubert. [Ruby 1.9 - Feature #5622] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r--ext/bigdecimal/bigdecimal.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 749d681071..8b5b68e8ea 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -312,6 +312,12 @@ BigDecimal_prec(VALUE self)
return obj;
}
+/*
+ * call-seq: hash
+ *
+ * Creates a hash for this BigDecimal. Two BigDecimals with equal sign,
+ * fractional part and exponent have the same hash.
+ */
static VALUE
BigDecimal_hash(VALUE self)
{
@@ -786,6 +792,14 @@ BigDecimal_coerce(VALUE self, VALUE other)
return obj;
}
+/*
+ * call-seq: +@
+ *
+ * Return self.
+ *
+ * e.g.
+ * b = +a # b == a
+ */
static VALUE
BigDecimal_uplus(VALUE self)
{
@@ -1052,6 +1066,14 @@ BigDecimal_ge(VALUE self, VALUE r)
return BigDecimalCmp(self, r, 'G');
}
+/*
+ * call-seq: -@
+ *
+ * Return the negation of self.
+ *
+ * e.g.
+ * b = -a # b == a * -1
+ */
static VALUE
BigDecimal_neg(VALUE self)
{
@@ -2929,8 +2951,10 @@ Init_bigdecimal(void)
rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE",INT2FIX(VP_SIGN_NEGATIVE_INFINITE));
arg = rb_str_new2("+Infinity");
+ /* Positive infinity value. */
rb_define_const(rb_cBigDecimal, "INFINITY", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
arg = rb_str_new2("NaN");
+ /* 'Not a Number' value. */
rb_define_const(rb_cBigDecimal, "NAN", BigDecimal_global_new(1, &arg, rb_cBigDecimal));