Andrew,
Where does the 2.51658E+07 come from? The mantissa of %10000000
00000000 00000000 = 8388608 which would come out right.
Is the "Binary value of variable" what you actually see (by looking at
memory) for a variable which is printed as 0.5?
Is there something going on with normalisation, where the top "1" bit is
assumed and omitted? If the value had been 1.5 and your calculation
worked out as 0.5 that would be an explanation, so maybe I'm
interpreting this backwards.
Lawrence
On Sun, 2008-07-27 at 21:39 +0100, Andrew Burton wrote:
Hi,
I am trying (and failing) to learn how AMOS Basic (and Amiga's) store floating point
numbers. Whilst it is clear that it uses Motorola Fast Floating Point (MFPP) I have been
unable to get it to work based on an equation found online (the Amiga RKRM's all say
to use the FPP functions in the maths libraries, and also confirm the layout - 24 bit
mantissa, 1bit sign, 7bit exponent).
Am I doing something wrong with my maths??
Formula:
FP result =[(-1)^SIGN] * [2^(EXP - 0x40)] * [MANTISSA / 0x1000000]
0x1000000 = 16,777,216
0x40=64
floating-point variable value=0.5
Binary value of variable=%10000000 00000000 00000000 01000000
Values calculated using formula (above):
SIGN=0 (positive)
EXPONENT=64 - 64 (bias) = 0
MANTISSA=2.51658 E+07 / 16,777,216 = 1.5
Thus:
result = [(-1)^SIGN] * [2^(EXP - 0x40)] * [MANTISSA / 0x1000000]
= [(-1)^0]*[2^(0)]*[1.5]
= 1*1*1.5
= 1.5!
I have uploaded a bitmap image of my maths to my site if it isn't clear from above
what I am doing.
http://www.geocities.com/aliensrcooluk/public/MFPP_problem.bmp
Please help!
Andrew B
aliensrcooluk at yahoo.co.uk
--
Lawrence Wilkinson lawrence at ljw.me.uk
The IBM 360/30 page
http://www.ljw.me.uk/ibm360