Jump to content
IGNORED

FP storage example in De Re


Recommended Posts

I'm curious about the passage on page 8-45 of De Re where it's talking about the memory representation of FP. The last two examples are:

 

Number: 37.0 = 37 * 100**0

 

Format: 40 37 00 00 00 00  (exponent= 40+0)

 

Number: -460312 = -46.0312 * 100**2

 

Format: C2 46 03 12 00 00  (exponent= 80+40+2)

 

So I'm wondering what the rule is here... is it simply that the exponent is changed until the leftmost digit of the mantissa is non-zero?

 

Does this imply that anything with exponent 100**0 ... 100**4  (40 ... 44) is directly readable? IE:

 

Number: 123456.0 = 12.3456 * 100**4

Format: 44 12 34 56 00 00  (exponent= 40+4)

Link to comment
Share on other sites

Storing the exponent with an offset is common - even in the IEEE floating point representation used in the current CPU's.

 

For C2 46 03 12 00 00 the exponent is C2 .
The top bit is the sign (ie $80 means negative). So we remove the top bit, leaving $42.
Then we remove the offset of $40, to leave $02.
The mantissa is 46 03 12, which is BCD for 46.0312 (implied decimal point is just after the first byte of the mantissa).
Treating the exponent and mantissas as BCD, this gives us 46.0312 * 100^2 = 46.0312 * 10000 = 460312 .
Remembering the sign, we now have -460312 .

 

40 12 34 56 00 00 therefore reads as 12.34560000 * 100^0 = 12.34560000
41 12 34 56 00 00 therefore reads as 12.34560000 * 100^1 = 1234.560000
42 12 34 56 00 00 therefore reads as 12.34560000 * 100^2 = 123456.0000
43 12 34 56 00 00 therefore reads as 12.34560000 * 100^3 = 12345600.00
44 12 34 56 00 00 therefore reads as 12.34560000 * 100^4 = 1234560000
3F 12 34 56 00 00 therefore reads as 12.34560000 * 100^-1 = 0.1234560000
3E 12 34 56 00 00 therefore reads as 12.34560000 * 100^-2 = 0.0012345600
and so on

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...