Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created June 13, 2011 15:30
Show Gist options
  • Save hadronized/1022994 to your computer and use it in GitHub Desktop.
Save hadronized/1022994 to your computer and use it in GitHub Desktop.
float comparison
/* is that sane ? */
float a = /* ... */
float b = /* ... */
if (a == b)
/* do something */
/* I always do that */
bool equals(float lhs, float rhs) {
return std::abs(lhs - rhs) < special_value<float>::EPSILON;
}
float a = /* ... */
float b = /* ... */
if (equals(a, b))
/* do something */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment