Auberon
Auberon

Reputation: 715

Maximum Decimal Exponent IEEE 754

The Wikipedia page on the IEEE 754 standard contains a table that summarizes different floating point representation formats. Here is an excerpt.

The Game

The meaning of the Decimal digits column is the number of digits the represented number its mantissa has if you convert it to decimal. The page states that it is computed by (Significand bits)*log_10(2). I can see how that makes sense.

However, I don't see what the meaning is of the Decimal E max column. It is computed by (E max)*log_10(2) and is supposed to be "the maximum exponent in decimal". But isn't E max the maximum exponent in decimal?

I'm asking because these 'decimal' values are the values (I think) that can be passed to selected_real_kind in Fortran. If you define a real with kind selected_real_kind(6, 37) it will be single precision. There will be (at least) 6 significand digits in your decimal number. So a similar question is, what is the meaning of the 37? This is also the value returned by Fortran's range. The GNU Fortran docs state that "RANGE(X) returns the decimal exponent range in the model of the type of X", but it doesn't help me understand what it means.

Upvotes: 0

Views: 544

Answers (1)

Auberon
Auberon

Reputation: 715

I always come up with an answer myself minutes after I've posted it on StackExchange even though I've been thinking about it all day...

The number in binary is represented by m*2^(e) with m the mantissa and e the exponent in binary. The maximum value of e for single precision is 127.

The number converted to decimal can be represented by m*10^(e) with m the mantissa and e the exponent in decimal. To have the same (single) precision here, e has a maximum value of 127*log_10(2) = 38.23. You can also see this by noticing m*10^(127*log_10(2)) = m*2^(127).

Upvotes: 1

Related Questions