Class: Numeric
Instance Method Summary collapse
-
#in_delta?(orig, delta = 0.001) ⇒ Boolean
(also: #close?)
Is self and given number within delta tolerance.
-
#in_epsilon?(orig, epsilon = 0.001) ⇒ Boolean
Verify epsilon tolerance.
Instance Method Details
#in_delta?(orig, delta = 0.001) ⇒ Boolean Also known as: close?
Is self and given number within delta tolerance.
0.05.in_delta?(50000.0 / 10**6, 0.00001)
107 108 109 110 |
# File 'lib/ae/core_ext/helpers.rb', line 107 def in_delta?(orig, delta=0.001) #(num.to_f - to_f).abs <= delta.to_f delta >= (orig - self).abs end |
#in_epsilon?(orig, epsilon = 0.001) ⇒ Boolean
Verify epsilon tolerance.
116 117 118 |
# File 'lib/ae/core_ext/helpers.rb', line 116 def in_epsilon?(orig, epsilon=0.001) in_delta?(orig, [orig, self].min * epsilon) end |