Skip to content

Instantly share code, notes, and snippets.

Created May 24, 2015 08:55
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 anonymous/3bf78122d2c95d2a63eb to your computer and use it in GitHub Desktop.
Save anonymous/3bf78122d2c95d2a63eb to your computer and use it in GitHub Desktop.
multiplyepsilon.cpp
#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