Hi,

When dealing with some small 32-bit floating point numbers I stumbled upon something unexpected.

What works as expected:

float a = 1e-30; // 1e-30

float b = 1 / a; // 1e+30

float c = sqrt(a); // 1e-15

But what surprised me:

float a = 1e-40; // 0.0

float b = 1 / a; // 1.#INF

float c = sqrt(a); // 0.0

I'm using a SHARC ADSP-21479 and CrossCore 1.1.1.0 and expected 32 bit floating point to be according to IEEE 754. But it seems the exponent cannot exceed 39?

Thanks in advance!

IEEE 754-1985 defines a range of +/- 3.4*10^38 for large numbers and +/- 1.2=10^-38 for small numbers (32 bit)

With an 8 bit exponent you have 2^127 to work with for large numbers.

This is a large range for real physical things. Generally when you see a NAN, you have made a mistake.

Al Clark