Skip to content

Commit ceaf16b

Browse files
committed
[Doc] Add documentation of BigDecimal#n_significant_digits
1 parent 4fbec55 commit ceaf16b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ext/bigdecimal/bigdecimal.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,22 @@ BigDecimal_scale(VALUE self)
481481
return SSIZET2NUM(scale);
482482
}
483483

484+
/*
485+
* call-seq:
486+
* n_significant_digits -> integer
487+
*
488+
* Returns the number of decimal significant digits in +self+.
489+
*
490+
* BigDecimal("0").scale # => 0
491+
* BigDecimal("1").scale # => 1
492+
* BigDecimal("1.1").scale # => 2
493+
* BigDecimal("3.1415").scale # => 5
494+
* BigDecimal("-1e20").precision # => 1
495+
* BigDecimal("1e-20").precision # => 1
496+
* BigDecimal("Infinity").scale # => 0
497+
* BigDecimal("-Infinity").scale # => 0
498+
* BigDecimal("NaN").scale # => 0
499+
*/
484500
static VALUE
485501
BigDecimal_n_significant_digits(VALUE self)
486502
{

0 commit comments

Comments
 (0)