Skip to content

Instantly share code, notes, and snippets.

@kotp
Created March 15, 2013 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotp/5173308 to your computer and use it in GitHub Desktop.
Save kotp/5173308 to your computer and use it in GitHub Desktop.
class Float
def near_enough?(other, epsilon = Float::EPSILON)
(self - other.to_f).abs < epsilon.to_f
end
end
@kotp
Copy link
Author

kotp commented Mar 16, 2013

Greatly error prone for floats less than 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment