Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting mouse to ignore outside of _NewImage PhilOfPerth 11 736 12-18-2025, 07:20 PM
Last Post: Pete
  random maze map. math help pmackay 4 572 08-10-2025, 11:22 AM
Last Post: pmackay
  GNU C++ Compiler error eoredson 55 8,193 12-26-2024, 05:27 AM
Last Post: eoredson
  Run code without compiler phil 9.0 7 1,327 12-05-2024, 08:52 AM
Last Post: phil 9.0
  Setting Line _RGB colours PhilOfPerth 10 1,974 11-03-2024, 05:37 AM
Last Post: PhilOfPerth

Forum Jump:


Users browsing this thread: 1 Guest(s)