Sign | Significand | Exponent | |||||||
---|---|---|---|---|---|---|---|---|---|
. | |||||||||
+ | 0.0 | 0 | |||||||
0x0000000000000000 | |||||||||
0b0000000000000000000000000000000000000000000000000000000000000000 | |||||||||
. | |||||||||
+ | 0.0 | 0 | |||||||
0x0000000000000000 | |||||||||
0b0000000000000000000000000000000000000000000000000000000000000000 | |||||||||
. | |||||||||
+ | 0.0 | 0 | |||||||
0x0000000000000000 | |||||||||
0b0000000000000000000000000000000000000000000000000000000000000000 |
This is a little calculator intended to help you understand the IEEE 754 standard for floating-point computation. It is implemented in JavaScript (using the amazing VanillaJS framework) and should work with recent desktop versions of Firefox and Chrome. I haven't tested with other browsers. (And on Chrome it looks a bit ugly because the input boxes are a tad too wide.)
Note that this is the new version of this calculator that was released in August 2023. The battle-tested old version from 2016 can be found here. If you find any deviations, please let me know!
If you enter a floating-point number in one of the three boxes
on the left and press the Enter key, you will see the
number's bit pattern on the right. You can enter numbers
using the syntax typically accepted in programming languages,
for example 42
, 2.345
, 12E-3
, and so on; you can input the values NaN
, Inf
, and -Inf
directly; and you can also enter fractions using the syntax 17/23
. Finally, you can use as input bit patterns as shown on the right (the ones starting with 0b
or 0x
).
Or you can do it the other way around and manipulate the bits on the right. Once you've pressed Enter,
the number to the left will be updated. In the exponent
field, instead of a bit pattern you can also enter a decimal
starting with +
or -
. (Note
that the red digit is the hidden bit and can't be changed directly.)
Press one of the four buttons to add, subtract, multiply, or divide the two numbers above the buttons and show the result below.
The rounding mode used is round to nearest, ties to even.
The code doesn't distinguish between quiet and signaling NaN
, i.e. all NaN
s are quiet and use the same bit pattern.
For decimal output, a naive version of the algorithm by Burger and Dybvig is employed. This might result in noticeable delays for 128-bit floats, especially for denormalized ones.
The IEEE standard defines various binary and decimal formats. The default format for this page is binary64, but you can use the buttons below to switch to some of the other variants.
Copyright (c) 2016–2023, Prof. Dr. Edmund Weitz. Impressum, Datenschutzerklärung.