Class: Float
Instance Method Summary collapse
-
#signif(numDigits = 3) ⇒ Object
Change to a float with a given number of significant digits.
-
#to_significant_digits(numDigits = 3) ⇒ Object
Change to a float with a given number of significant digits.
Instance Method Details
#signif(numDigits = 3) ⇒ Object
Change to a float with a given number of significant digits.
31 32 33 34 |
# File 'lib/feldtruby/float.rb', line 31 def signif(numDigits = 3) return self if self == INFINITY || self == -INFINITY Float("%.#{numDigits}g" % self) end |
#to_significant_digits(numDigits = 3) ⇒ Object
Change to a float with a given number of significant digits.
37 38 39 |
# File 'lib/feldtruby/float.rb', line 37 def to_significant_digits(numDigits = 3) signif(numDigits) end |