Created
July 23, 2010 18:14
-
-
Save jstewart/487809 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Float | |
def approx_equal?(other,threshold) | |
if (self-other).abs<threshold # "<" not exact either ;-) | |
return true | |
else | |
return false | |
end | |
end | |
end | |
a=0.1 | |
b=1.0-0.9 | |
threshold=10**(-5) | |
p a.approx_equal?(b,threshold) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment