Yes, using the FPU directly, and with everything at the defaults I get 1267, but by changing the rounding mode I can get 1266.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
FRC_NEAREST equ 0 ; or to even if equidistant (initialized state)
FRC_DOWN equ 400h ; toward -infinity
FRC_UP equ 800h ; toward +inifinity
FRC_TRUNCATE equ 0c00h ; toward zero
SETRC MACRO rc
IFNDEF __fpu__cw__
.data?
__fpu__cw__ dw ?
.code
ENDIF
fstcw __fpu__cw__
and __fpu__cw__, NOT 0c00h
or __fpu__cw__, rc
fldcw __fpu__cw__
ENDM
;==============================================================================
.data
.code
;==============================================================================
foo proc d:REAL8
printf("%.15G\n", d)
fld8 100.0
fld d
fmul
push eax
fistp DWORD PTR [esp]
pop eax
ret
foo endp
;==============================================================================
start:
;==============================================================================
invoke foo, FP8(12.67)
printf("%d\n",eax)
SETRC FRC_DOWN
invoke foo, FP8(12.67)
printf("%d\n",eax)
SETRC FRC_UP
invoke foo, FP8(12.67)
printf("%d\n",eax)
SETRC FRC_TRUNCATE
invoke foo, FP8(12.67)
printf("%d\n\n",eax)
inkey
exit
;==============================================================================
end start
12.67
1267
12.67
1266
12.67
1267
12.67
1266
In the C code you should be able to display the current FPU rounding mode, but then there is the possibility that one is using SSE2 instead of the FPU, and I can’t conveniently test the effects of that ATM.