Created
June 13, 2011 15:30
-
-
Save hadronized/1022994 to your computer and use it in GitHub Desktop.
float comparison
This file contains 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
/* 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