Scientific Notation
#4
Actually, I think you need a semi colon, not a comma there...

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
Reply


Messages In This Thread
Scientific Notation - by james2464 - 11-10-2022, 04:27 AM
RE: Scientific Notation - by BSpinoza - 11-10-2022, 04:56 AM
RE: Scientific Notation - by james2464 - 11-10-2022, 05:31 AM
RE: Scientific Notation - by Pete - 11-10-2022, 09:55 AM
RE: Scientific Notation - by bplus - 11-10-2022, 04:02 PM
RE: Scientific Notation - by mnrvovrfc - 11-10-2022, 04:52 PM
RE: Scientific Notation - by james2464 - 11-10-2022, 03:54 PM
RE: Scientific Notation - by bplus - 11-10-2022, 04:36 PM
RE: Scientific Notation - by Pete - 11-10-2022, 04:41 PM
RE: Scientific Notation - by bplus - 11-10-2022, 05:18 PM
RE: Scientific Notation - by Pete - 11-10-2022, 05:37 PM
RE: Scientific Notation - by SMcNeill - 11-10-2022, 08:03 PM
RE: Scientific Notation - by bplus - 11-10-2022, 08:43 PM
RE: Scientific Notation - by Pete - 11-10-2022, 09:40 PM



Users browsing this thread: 5 Guest(s)