Message board for the users of flat assembler.
> DOS > Float 16bit?
I'm trying to use float in 16bit environment. But I can't figure out how to declare an single precision float.
This is what I'm trying to do.
Sin dd 0.173648f ;Sin 10 degrees mov ax,word [Sin] mov dx,word [Sin+2]
The result is: dx:ax = 1|11110001|100011101000011001000 = Very large negative number.
Are all declared float treated as double precision?
|24 Oct 2005, 13:34||
Hehe, if you read my previous post you can atleast see one error in it. I'm trying to represent a double word with 30bits.
What I have learned from this is to never trust Microsoft's calculator as it cuts of ending zeros. The bits should look like this:
If I have understood floating numbers this is how it works. Lets say we have bit 0 to the right and bit 31 to the left.
Bit31 = 1 if negative otherwise 0
Bit23-30 = Exponent
Bit0-22(23) = Mantissa
Bit23 is a very special bit since it being assumed to be 1 when used together with mantissa even if it is 0 in my example above. It is only assumed to be 0 in special cases. The mantissa is represented like this when you calculate it:
If you want to make it easy on yourself you put everything after the dot in a calculator converts it to decimal and divide it by 2^23 and then add 1.
What I tried to represent as a dw was 0.173648 if you do the calculation from my bits above you get. 1*2^(124-127)*1.389183=0.1736478. So it seems my previous code was right and Fasm handles my Sin value as single precision.
If you would like to know more about float go here http://stevehollasch.com/cgindex/coding/ieeefloat.html
Hopefully this helps some confused float newbies as myself.
|24 Oct 2005, 20:34||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar.
Powered by rwasa.