Can anyone tell me why the following code gives me a remainder of -0.4655 not +0.4655?
include 'macro.inc' ; that's mine, based on win32ax.inc
.data
_Const4 dq 1.2
_Const5 dq 0.7345
FltWrk dd ?
.code
start:
fninit ;; initialise FPU
fnstcw word[FltWrk]
or word[FltWrk],0x0C00 ;; set rounding mode as truncate towards zero (for floor())
fldcw word[FltWrk]
;if rmdr(1.2,0.7345)!=0.4655 then puts(1,"rmdr(1.2,0.7345)!=0.4655\n") abort(1) end if
fld [_Const4]
fld [_Const5]
@@:
fprem1
fstsw ax
and ah,1
jnz @b
fstp ST1
invoke ExitProcess,0
.end start
Update: I now think I was a bit infatuated with "IEEE754" and the docs saying "all new softare should use fprem1, not fprem". I managed to get the expected result by changing to fprem and swapping the flds.