Class: Float
- Inherits:
-
Object
- Object
- Float
- Defined in:
- lib/ferret/number_tools.rb
Instance Method Summary collapse
-
#=~(o, precision = 0.0000000001) ⇒ Object
Return true if the float is within
precision
of the other valueo
.
Instance Method Details
#=~(o, precision = 0.0000000001) ⇒ Object
Return true if the float is within precision
of the other value o
. This is used to accommodate for floating point errors.
- o
-
value to compare with
- precision
-
the precision to use in the comparison.
- return
-
true if the match is within
precision
11 12 13 |
# File 'lib/ferret/number_tools.rb', line 11 def =~(o, precision = 0.0000000001) return (1 - self/o).abs < precision end |