Class: Float

Inherits:
Object show all
Defined in:
lib/feldtruby/float.rb

Instance Method Summary collapse

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