Created
October 5, 2022 02:42
-
-
Save mebjas/719e0a3ad53fd9564ea7c5b74c12ab9a to your computer and use it in GitHub Desktop.
Code with equality check on floating values
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
constexpr int kIterations = 10000000; | |
int counter = 0; | |
for (int i = 0; i < kIterations; ++i) { | |
float a = 0.151f + 0.151f; | |
float b = 0.101f + 0.201f; | |
bool d = (a == b); | |
if (d) { | |
counter++; | |
} | |
} | |
std::cout << "Counter = " << counter << "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment