The reason is that all internal thinBasic numeric calculations are performed using EXTENDED numeric type, that has 18 digits of precision.
When you call FRAC, it rounds the result of fit the precision of the EXTENDED data type.
Then the EXTENDED result is assigned to your DOUBLE variable.
Also when you PRINT a number thinBasic convert you numeric variable into an EXTENDED number before printing it.
So your DOUBLE variable is OK internally but output must be controlled.
I do not think there are problems in calculations unless you need to save/printl data somewhere. At that point you need to control the output using some rounding functions
You can use ROUND function to return the number of decimals you need:
'---Load Console Module
Uses "Console"
Dim JD As double
Dim F As double
JD = 2436116.31
PrintL(jd & " = JD")
PrintL(Round(Frac(JD), 6) & " = frac(JD)")
PrintL
F = Round(Frac(JD), 6)
PrintL(F & " = F" )
PrintL "Press a key to end program"
WaitKey
Also STR$(...), TSTR$(...), FORMAT$(...) can be used to control number of decimals to output.
Found something on Power Basic (the compiler I use to create thinBasic) forum regarding this:
https://forum.powerbasic.com/forum/u...-in-powerbasic
Bookmarks