Could not load WASM!
License Source
Calculator mode:

Double-precision (64-bit) floating-point number

Link

Empty stack

Enter a value, or try one of these:

(Thanks to Ned Batchelder for inspiration on some of these.)

Bits

Sign

= =

Exponent

= =

Fraction

 =
=

Value

(-1) × (1 + /2 52) × 2 - 1023
= × 2

Since the exponent is , the sign is , and the fraction is 0, this represents the floating point number 0.

Since the sign is , the exponent is 0x7ff = 2047, and the fraction is 0, this represents the floating point number .

Since the exponent is 0x7ff = 2047, and the fraction is non-zero, this represents the floating point number NaN (not a number).

Text and hex representation

On the left is the text representation the floating-point number as typically presented to a user. The letter e does not indicate the familiar constant approximately equal to 2.718281828459045, but is short for exponent, and is part of an old-school way of showing scientific notation without superscripts. For example, both 1.234e30 and 1.234e+30 represent the value 1.234 × 1030, while 1.234e-30 represents the value 1.234 × 10-30.

On the right is the hexadecimal (base-16) representation of the floating-point number as stored in memory. This is explained in the next help topic, Bits.

Bits

This shows how the floating-point number is represented in the computer, in binary. (The hexadecimal representation is given above.)

There are three parts: the sign (1 bit), the exponent (11 bits), and the fraction (52 bits).

Sign

This one bit represents the sign of the floating-point number. It the bit is zero, the number is positive. If the bit is one, the number is negative.

Exponent

These 11 bits give the exponent of the floating-point number, after 1023 is added.

For example, if 1025 is stored here, then the true exponent is 2. On the other hand, if 1000 is stored here, then the true exponent is -23.

If the exponent is 0 and the fraction part is 0, then the floating point number is ±0 (the sign being determined by the sign bit).

If the exponent is 0x7ff = 2047 and the fraction part is 0, then the floating point number is ±∞ (the sign being determined by the sign bit).

If the exponent is 0x7ff = 2047 and the fraction part is nonzero, then the floating point number is NaN (not a number).

Fraction

In scientific notation, non-zero numbers are written in decimal in the form ± d0 . d1 d2 d3 dk × 10n = ± ( Σ j=0 k dj 10j ) × 10n , where 1d0 9 and 0dj 9 for 1jk .

Likewise, the idea behind floating-point numbers is to represent most numbers (all except for ±0, ±∞, and NaN) in a binary analogue to scientific notation, ± ( b0 . b1 b2 b3 b52 ) 2 × 2n = ± ( Σ j=0 52 bj 2j ) × 2n , where b0 =1 and 0bj 1 for 1j52 . (Here, the value ( b0 . b1 b2 b3 b52 ) 2 is written in binary.) Since b0=1 always, we don't bother storing it. The 52 binary digits b1, b2, b3, , b52 are the fraction bits for the floating-point number.

Value

Except in the cases of ±0, ±∞, or NaN, a floating-point number x is represented as x = ( -1 ) s × ( 1 . b1 b2 b3 b52 ) 2 × 2n x = ( -1 ) s × ( 1 + Σ j=1 52 bj 2j ) × 2n . If we set e=n+1023 and f= ( b1 b2 b3 b52 ) 2 = Σ j=1 52 2 53 - j b j , then x = ( -1 ) s × ( 1 + f 252 ) × 2 e-1023 . The values s, e, and f are the sign, exponent, and fraction part of the float, respectively.