Skip to content

Commit

Permalink
[Doc] Add documentation of BigDecimal#n_significant_digits
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkn committed Dec 2, 2021
1 parent 4fbec55 commit ceaf16b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ext/bigdecimal/bigdecimal.c
Expand Up @@ -481,6 +481,22 @@ BigDecimal_scale(VALUE self)
return SSIZET2NUM(scale);
}

/*
* call-seq:
* n_significant_digits -> integer
*
* Returns the number of decimal significant digits in +self+.
*
* BigDecimal("0").scale # => 0
* BigDecimal("1").scale # => 1
* BigDecimal("1.1").scale # => 2
* BigDecimal("3.1415").scale # => 5
* BigDecimal("-1e20").precision # => 1
* BigDecimal("1e-20").precision # => 1
* BigDecimal("Infinity").scale # => 0
* BigDecimal("-Infinity").scale # => 0
* BigDecimal("NaN").scale # => 0
*/
static VALUE
BigDecimal_n_significant_digits(VALUE self)
{
Expand Down

0 comments on commit ceaf16b

Please sign in to comment.