Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

max float represented in IEEE 754

I am wondering if the max float represented in IEEE 754 is:

(1.11111111111111111111111)_b*2^[(11111111)_b-127]

Here _b means binary representation. But that value is 3.403201383*10^38, which is different from 3.402823669*10^38, which is (1.0)_b*2^[(11111111)_b-127] and given by for example c++ <limits>. Isn't (1.11111111111111111111111)_b*2^[(11111111)_b-127] representable and larger in the framework?

Does anybody know why?

Thank you.

like image 922
Qiang Li Avatar asked Apr 19 '12 17:04

Qiang Li


People also ask

How many numbers can be represented with IEEE 754?

So there are 2^32 - 2^25 = 4261412864 distinct normal numbers in the IEEE 754 binary32 format.

What is the IEEE 754 standard for floating-point representation?

The IEEE-754 standard describes floating-point formats, a way to represent real numbers in hardware. There are at least five internal formats for floating-point numbers that are representable in hardware targeted by the MSVC compiler. The compiler only uses two of them.

What is the largest positive decimal number we can represent using IEEE 754 floating-point representation?

Consequently, the smallest non-zero positive number that can be represented is 1×10−101, and the largest is 9999999×1090 (9.999999×1096), so the full range of numbers is −9.999999×1096 through 9.999999×1096.


2 Answers

The exponent 11111111b is reserved for infinities and NaNs, so your number cannot be represented.

The greatest value that can be represented in single precision, approximately 3.4028235×1038, is actually 1.11111111111111111111111b×211111110b-127.

See also http://en.wikipedia.org/wiki/Single-precision_floating-point_format

like image 172
Joni Avatar answered Oct 06 '22 14:10

Joni


Being the "m" the mantisa and the "e" the exponent, the answer is:

enter image description here

In your case, if the number of bits on IEEE 754 are:

  • 16 Bits you have 1 for the sign, 5 for the exponent and 10 for the mantissa. The largest number represented is 4,293,918,720.
  • 32 Bits you have 1 for the sign, 8 for the exponent and 23 for the mantissa. The largest number represented is 3.402823466E38
  • 64 Bits you have 1 for the sign, 11 for the exponent and 52 for the mantissa. The largest number represented is 2^1024 - 2^971
like image 22
Fernando Pérez Lara Avatar answered Oct 06 '22 13:10

Fernando Pérez Lara