Created
May 24, 2015 08:55
-
-
Save anonymous/3bf78122d2c95d2a63eb to your computer and use it in GitHub Desktop.
multiplyepsilon.cpp
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
#include <iostream> | |
void large_range_check(float low, float high) { | |
float range = high - low; | |
float little_bit_small_range = (high - low) * (1.0f - std::numeric_limits<float>::epsilon()); | |
printf("%x\n", *(reinterpret_cast<int *>(&range))); | |
printf("%x\n", *(reinterpret_cast<int *>(&little_bit_small_range))); | |
} | |
int main(){ | |
large_range_check(0.0f, std::numeric_limits<float>::max()); | |
large_range_check(0.0f, 3.0f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment