Compiler setting for accurate math?
#9
(11-30-2022, 07:49 PM)James D Jarvis Wrote: Why does this happen?   

[Image: image.png]

when this is the code?
Code: (Select All)
Dim x
For x = 1 To .05 Step -.05
    Print x
    _Delay x
Next x


Is there a complier setting to keep this from happening?

The lesson is don't trust a single index in a FOR loop with < 1 steps. It gets off track by as much as half the step value.
Here is equivalent that works better:
Code: (Select All)
Dim x
For x = 100 To 5 Step -5
    i = i + 1: Print i, x / 100
    _Delay x / 100 ' <<< why ??  accuracy .001
Next x
b = b + ...
Reply


Messages In This Thread
RE: Compiler setting for accurate math? - by Jack - 11-30-2022, 11:48 PM
RE: Compiler setting for accurate math? - by Pete - 12-01-2022, 04:26 AM
RE: Compiler setting for accurate math? - by Pete - 12-01-2022, 10:43 AM
RE: Compiler setting for accurate math? - by bplus - 12-01-2022, 04:51 PM
RE: Compiler setting for accurate math? - by Pete - 12-01-2022, 04:52 PM
RE: Compiler setting for accurate math? - by Pete - 12-01-2022, 10:16 PM



Users browsing this thread: 5 Guest(s)