I am trying to find the minimum value (closest to zero) that I can save in a single point with a floating point. Using the header <limits>, I can get the value, but if I make it much smaller, the float can still hold it and it will give the correct result. Here is a test program compiled with g ++ 5.3.0.
#include <limits>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float a = numeric_limits<float>::max();
float b = numeric_limits<float>::min();
a = a*2;
b = b/pow(2,23);
cout << a << endl;
cout << b << endl;
}
As I expected, "a" gives infinity, but "b" retains a good result even after dividing the minimum value by 2 ^ 23, after which it gives 0.
The value that gives numeric_limits<float>::min()is 2 ^ (- 126), which I believe is the correct answer, but why does the float on my program have such small numbers?