Java Reference
In-Depth Information
Thepositionalweightofthebinarydigitscanbeusedtoconvertabi-
narynumbertoitsdecimalequivalent.Asimilarmethodcanbeusedto
convertthefractionalpartofabinarynumbertoadecimalfraction,as
follows
.10101
|||
.500 _____________________| | |
.125 _________________________| |
.03125 ____________________________|
------
.65625
Fixed-point representations
Theencodingandstorageofrealnumbersinbinaryformpresentsseveral
difficulties.Thefirstoneisrelatedtothepositionoftheradixpoint.Since
thereareonlytwosymbolsinthebinaryset,andbothareusedtorepresent
thenumericalvalueofthenumber,thereisnoothersymbolavailablefor
representingtheradixpoint.Thedecimalnumber58.125canberepre-
sentedbyusingoneelementtoencodetheintegerpart,andanotheronefor
thefractionalpart,forexample:
58 = 111010B
.125 = .001B
Inlonghanddecimals,youcanwrite58.125,butincomputersitisim-
possibletoexplicitlyencodeabinaryfraction.Onepossibleschemefor
representingbinaryfractionsistoassumethattheradixpointislocated
atafixedposition. Figure20-3 showsonepossibleconventionforstoring
arealnumberinafixedpointbinaryformat.
binary
decimal
= 00111010 00100000 = 58.125
implied binarypoint
Figure20-3BinaryFixed-PointRepresentation
Figure20-3 assumesthatthebinarypointispositionedbetweenthe
eighthandtheninthdigitoftheencoding.Afixedpointrepresentationas-
sumes that there are a certain number of digits to the left and right of the
decimal point, which is the greatest limitation of the fixed point formats.
Suppose you wanted to store the value 312.250. This number can be rep-
resented in binary as follows:
 
Search WWH ::




Custom Search