Hi all. In last days I'm trying to work a bit with floating-point numbers in x86 assembly. I have processed to state when I need to get remainder of floating point division. I know that FPU does not offer anything like this but I still need it. Is there any simple way how to do it? I was thinking of decreasing or increasing (depending on if it's signed or not) number by divisor until it reaches or passes zero and then getting difference or sum (again depending on sign) between last result and divisor. Here's example of my idea:
Compare the speed of performing 1/0.000001 with your method and the speed of executing 1/0.000001 in C code. Wouldn't you have a better place to start if you use the faster method to get yourself an approximation first?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
iansjack: as you've written here, I googled it but it seems like it calculates just partial remainder and I have no idea how can I work with it also. MSVC++ is the only place I get information about how do the floating point numbers work, but C++ does not support this operation.
chaoscode: I can see your point but (int)doublevar seems to be not valid in C and also I have no idea about how to write it in assembly. I think you meant something like round when writing explicit conversion.
Back to FPREM, does anybody have any idea how to use it?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
fld dword [_divide] ;load 25.3
fld dword [_tobedivided] ;load 100.4
.again:
fprem ;do
fstsw ax ;move status word to ax
fwait
bt ax, 10 ;test C2 bit
jc .again ;if it's 1, do it again