What are the smallest positive values in C++ for which their multiplicative inverse will still be finite?
Have tried numeric_limits<double>::epsilon()
but it isn't it - am getting positive values for much smaller values than that.
#include <limits>//is it here?
void tfuuuuu()
{
double d_eps,invd_eps;
float f_eps,invf_eps;
invd_eps = 1.0/d_eps;//invd_eps should be finite
invf_eps = 1.f/f_eps;//invf_eps should be finite
}
I doubt there is a standard library function for finding the number you need, however, it is not too hard to find the needed value using a simple binary search:
The output of the script above:
Here is a starting point to answer your question. I have simply divided by 2. Once you get to dividing by 2^^148, you come pretty close. You could then iteratively move closer and print out the hex representation of the number to see what the compiler is doing:
Output: