* ext/bigdecimal/bigdecimal.c: [DOC] several fixes by @chastell

This includes fixing the capitalization of Infinity, return value of
  example "BigDecimal.new('NaN') == 0.0", and code style in example.
  [Fixes GH-398] https://github.com/ruby/ruby/pull/398


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
zzak 2013-09-26 13:13:59 +00:00
parent 327cd07708
commit 8603fdcc62
2 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,10 @@
Thu Sep 26 22:11:56 2013 Zachary Scott <e@zzak.io>
* ext/bigdecimal/bigdecimal.c: [DOC] several fixes by @chastell
This includes fixing the capitalization of Infinity, return value of
example "BigDecimal.new('NaN') == 0.0", and code style in example.
[Fixes GH-398] https://github.com/ruby/ruby/pull/398
Thu Sep 26 22:08:11 2013 Zachary Scott <e@zzak.io> Thu Sep 26 22:08:11 2013 Zachary Scott <e@zzak.io>
* lib/observer.rb: [DOC] syntax improvement in example by @chastell * lib/observer.rb: [DOC] syntax improvement in example by @chastell

View File

@ -449,10 +449,10 @@ check_rounding_mode(VALUE const v)
* When computation continues, results are as follows: * When computation continues, results are as follows:
* *
* EXCEPTION_NaN:: NaN * EXCEPTION_NaN:: NaN
* EXCEPTION_INFINITY:: +infinity or -infinity * EXCEPTION_INFINITY:: +Infinity or -Infinity
* EXCEPTION_UNDERFLOW:: 0 * EXCEPTION_UNDERFLOW:: 0
* EXCEPTION_OVERFLOW:: +infinity or -infinity * EXCEPTION_OVERFLOW:: +Infinity or -Infinity
* EXCEPTION_ZERODIVIDE:: +infinity or -infinity * EXCEPTION_ZERODIVIDE:: +Infinity or -Infinity
* *
* One value of the mode parameter controls the rounding of numeric values: * One value of the mode parameter controls the rounding of numeric values:
* BigDecimal::ROUND_MODE. The values it can take are: * BigDecimal::ROUND_MODE. The values it can take are:
@ -598,7 +598,7 @@ BigDecimal_IsNaN(VALUE self)
} }
/* Returns nil, -1, or +1 depending on whether the value is finite, /* Returns nil, -1, or +1 depending on whether the value is finite,
* -infinity, or +infinity. * -Infinity, or +Infinity.
*/ */
static VALUE static VALUE
BigDecimal_IsInfinite(VALUE self) BigDecimal_IsInfinite(VALUE self)
@ -2552,8 +2552,8 @@ BigDecimal_limit(int argc, VALUE *argv, VALUE self)
* BigDecimal::SIGN_NaN:: value is Not a Number * BigDecimal::SIGN_NaN:: value is Not a Number
* BigDecimal::SIGN_POSITIVE_ZERO:: value is +0 * BigDecimal::SIGN_POSITIVE_ZERO:: value is +0
* BigDecimal::SIGN_NEGATIVE_ZERO:: value is -0 * BigDecimal::SIGN_NEGATIVE_ZERO:: value is -0
* BigDecimal::SIGN_POSITIVE_INFINITE:: value is +infinity * BigDecimal::SIGN_POSITIVE_INFINITE:: value is +Infinity
* BigDecimal::SIGN_NEGATIVE_INFINITE:: value is -infinity * BigDecimal::SIGN_NEGATIVE_INFINITE:: value is -Infinity
* BigDecimal::SIGN_POSITIVE_FINITE:: value is positive * BigDecimal::SIGN_POSITIVE_FINITE:: value is positive
* BigDecimal::SIGN_NEGATIVE_FINITE:: value is negative * BigDecimal::SIGN_NEGATIVE_FINITE:: value is negative
*/ */
@ -2957,7 +2957,7 @@ get_vp_value:
* For example, try: * For example, try:
* *
* sum = 0 * sum = 0
* for i in (1..10000) * 10_000.times do
* sum = sum + 0.0001 * sum = sum + 0.0001
* end * end
* print sum #=> 0.9999999999999062 * print sum #=> 0.9999999999999062
@ -2967,7 +2967,7 @@ get_vp_value:
* require 'bigdecimal' * require 'bigdecimal'
* *
* sum = BigDecimal.new("0") * sum = BigDecimal.new("0")
* for i in (1..10000) * 10_000.times do
* sum = sum + BigDecimal.new("0.0001") * sum = sum + BigDecimal.new("0.0001")
* end * end
* print sum #=> 0.1E1 * print sum #=> 0.1E1
@ -2988,8 +2988,8 @@ get_vp_value:
* BigDecimal sometimes needs to return infinity, for example if you divide * BigDecimal sometimes needs to return infinity, for example if you divide
* a value by zero. * a value by zero.
* *
* BigDecimal.new("1.0") / BigDecimal.new("0.0") #=> infinity * BigDecimal.new("1.0") / BigDecimal.new("0.0") #=> Infinity
* BigDecimal.new("-1.0") / BigDecimal.new("0.0") #=> -infinity * BigDecimal.new("-1.0") / BigDecimal.new("0.0") #=> -Infinity
* *
* You can represent infinite numbers to BigDecimal using the strings * You can represent infinite numbers to BigDecimal using the strings
* <code>'Infinity'</code>, <code>'+Infinity'</code> and * <code>'Infinity'</code>, <code>'+Infinity'</code> and
@ -3009,8 +3009,8 @@ get_vp_value:
* NaN is never considered to be the same as any other value, even NaN itself: * NaN is never considered to be the same as any other value, even NaN itself:
* *
* n = BigDecimal.new('NaN') * n = BigDecimal.new('NaN')
* n == 0.0 #=> nil * n == 0.0 #=> false
* n == n #=> nil * n == n #=> false
* *
* === Positive and negative zero * === Positive and negative zero
* *
@ -3152,10 +3152,10 @@ Init_bigdecimal(void)
* See BigDecimal.mode. * See BigDecimal.mode.
*/ */
rb_define_const(rb_cBigDecimal, "ROUND_HALF_DOWN", INT2FIX(VP_ROUND_HALF_DOWN)); rb_define_const(rb_cBigDecimal, "ROUND_HALF_DOWN", INT2FIX(VP_ROUND_HALF_DOWN));
/* 5: Round towards +infinity. See BigDecimal.mode. */ /* 5: Round towards +Infinity. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_CEILING", INT2FIX(VP_ROUND_CEIL)); rb_define_const(rb_cBigDecimal, "ROUND_CEILING", INT2FIX(VP_ROUND_CEIL));
/* 6: Round towards -infinity. See BigDecimal.mode. */ /* 6: Round towards -Infinity. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_FLOOR", INT2FIX(VP_ROUND_FLOOR)); rb_define_const(rb_cBigDecimal, "ROUND_FLOOR", INT2FIX(VP_ROUND_FLOOR));
/* 7: Round towards the even neighbor. See BigDecimal.mode. */ /* 7: Round towards the even neighbor. See BigDecimal.mode. */