We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4fbec55 commit ceaf16bCopy full SHA for ceaf16b
ext/bigdecimal/bigdecimal.c
@@ -481,6 +481,22 @@ BigDecimal_scale(VALUE self)
481
return SSIZET2NUM(scale);
482
}
483
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
+ */
500
static VALUE
501
BigDecimal_n_significant_digits(VALUE self)
502
{
0 commit comments