11-10-2022, 09:55 AM
Actually, I think you need a semi colon, not a comma there...
Anyway, there are a lot of these floating point bombs to contend with.Here's two simple addition ones that differ with variable types.
PRINT USING and FIX() are a couple of workarounds but for better reliability across a large number spectrum you need to consider using something like my string math routine, I believe Mark and Steve have ones of their own, too, or Jack's excellent numeric dec-float routine. Of course you need to call these as libraries and add them with an $INCLUDE statement or just get comfortable with a sub addition that consists of several hundreds of lines.
Pete
Code: (Select All)
PRINT USING "####.##########"; a
Anyway, there are a lot of these floating point bombs to contend with.Here's two simple addition ones that differ with variable types.
Code: (Select All)
DIM a AS DOUBLE
FOR i = 1 TO 10
a = a + .01
PRINT a ' Bombs at iteration 7.
NEXT
DIM b as SINGLE
FOR i = 1 TO 10
b = b + .01
PRINT b ' Bombs at iteration 10.
NEXT
PRINT USING and FIX() are a couple of workarounds but for better reliability across a large number spectrum you need to consider using something like my string math routine, I believe Mark and Steve have ones of their own, too, or Jack's excellent numeric dec-float routine. Of course you need to call these as libraries and add them with an $INCLUDE statement or just get comfortable with a sub addition that consists of several hundreds of lines.
Pete