PHYS 2411
COMPUTATIONAL SCIENCE I

Fall Semester, 1998

Instructor: Joel E. Tohline
tohline@rouge.phys.lsu.edu

Representing Floating Point Numbers in Binary
Page last updated:

Binary Representation of Java [float] Data Type
Decimal
Number
sign bit 8-bit exponent 23-bit mantissa example
f s e M
1/2 =
0
1000 0000
100 0000 0000 0000 0000 0000
(a)
3 =
0
1000 0010
110 0000 0000 0000 0000 0000
(b)
1/4 =
0
0111 1111
100 0000 0000 0000 0000 0000
(c)
10-7 =
0
0110 1001
110 1011 0101 1111 1100 1010
(d)
=
0
1000 0010
000 0000 0000 0000 0000 0000
(e)
3 + 10-7 =
0
1000 0010
110 0000 0000 0000 0000 0000
(f)

These examples have been taken directly from Figure 1.2.1 of the "Numerical Recipes" textbook. The correct (decimal) number "f" is actually derived from the tabulated information as follows:

f = s x M x B(e - E),

where, B = 2 (base 2 arithmetic) and E = 151 (the bias) = 128 + 23.


| Syllabus | Textbooks |
| Calendar | Q1 | Q2 | Q3 | Q4 |