Hi JJ,
long time. I am not too well lately.
-------------------------------------------
include \masm32\MasmBasic\MasmBasic.inc ; download
Init
FINIT ; It is good programming practice to take the precaution of initializing FPU before starting any computation
FFREE st(0)
INVOKE crt_atof,offset teststring1
Print Str$("\n%Hf", ST(0))
FFREE ST(0)
INVOKE crt_atof,offset teststring2
Print Str$("\n%Hf\n\n", ST(0))
invoke crt_printf, cfm$("%f\n"), test1
invoke crt_printf, cfm$("%f\n\n"), test2
inkey
Exit
.data
teststring1 db "10.123456789",0
teststring2 db "10.123456",0
test1 REAL8 10.123456789
test2 REAL8 10.123456
end start
;output
;10.123456789000000 ok.
;10.123455999999999 ???
;10.123457 Where is 6
;10.123456 ok.
;It takes 10 seconds for the first run - than it starts immediately
Quote from: clamicun on July 13, 2016, 12:28:59 AM
Hi JJ,
long time. I am not too well lately.
Hi Clamicun,
Very sorry to hear that, I hope it's only temporary :icon14:
Quote;It takes 10 seconds for the first run - than it starts immediately
The 10 seconds seem to be a problem of your machine - antivirus??
The precision problems are natural. This is what you get with a REAL8, and the CRT doesn't offer REAL10. See below some comments.
Hope you'll get better soon.
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
; FINIT ; It is good programming practice ... indeed, that's why MasmBasic Init does that for you
; FFREE st(0) ; no need for that, it's already free after finit; besides, you free st(7) if needed
INVOKE crt_atof,offset teststring1
Print Str$("\n%Jf", ST(0))
fstp test1
; FFREE ST(0) ; not needed
INVOKE crt_atof,offset teststring2
Print Str$("\n%Jf\n\n", ST(0))
fstp test2
invoke crt_printf, cfm$("%.17f\n"), test1
invoke crt_printf, cfm$("%.17f\n\n"), test2
MovVal ST(0), offset teststring1
Print Str$("\n%Jf MovVal()\n", ST(0)#)
MovVal ST(0), offset teststring2
Print Str$("%Jf MovVal()\n\n", ST(0)#)
Inkey "Better?"
Exit
.data
teststring1 db "10.123456789012345678",0
teststring2 db "10.123456000000000000",0
test1 REAL8 ?
test2 REAL8 ?
end start
10.12345678901234614
10.12345599999999912
10.12345678901234600
10.12345599999999900
10.12345678901234568 MovVal()
10.12345600000000000 MovVal()
Better?
JJ, thanks a lot.
Temporarily ???
Chemotherapy and Radiotherapy is serious business.
----------------------------------------
Yes of course it is the antivirus.
And the prog is much "Better".
Have a good one.
Clamicun
I keep my fingers crossed for the success of your "serious business" :icon14: