Class: Numeric
Instance Method Summary collapse
-
#in_delta?(orig, delta = 0.001) ⇒ Boolean
Is the number within
deltaof another?. -
#in_epsilon?(orig, epsilon = 0.001) ⇒ Boolean
Is the number within
epsilonof another, relative to the smaller of the two magnitudes?.
Instance Method Details
#in_delta?(orig, delta = 0.001) ⇒ Boolean
Is the number within delta of another?
0.05.in_delta?(50000.0 / 10**6, 0.00001)
58 59 60 |
# File 'lib/assay/ae/core_ext.rb', line 58 def in_delta?(orig, delta=0.001) delta >= (orig - self).abs end |
#in_epsilon?(orig, epsilon = 0.001) ⇒ Boolean
Is the number within epsilon of another, relative to the smaller
of the two magnitudes?
64 65 66 |
# File 'lib/assay/ae/core_ext.rb', line 64 def in_epsilon?(orig, epsilon=0.001) in_delta?(orig, [orig.abs, self.abs].min * epsilon) end |