08-27-2022, 03:26 AM
(This post was last modified: 08-27-2022, 03:28 AM by dcromley.
Edit Reason: ")"
)
Interesting! Thanks.
You could replace a few 6-statement sequences with 1 statement.
It's kind of like a remainder, except the divisor can be non-integer.
I hope the commented code explains it.
You could replace a few 6-statement sequences with 1 statement.
It's kind of like a remainder, except the divisor can be non-integer.
I hope the commented code explains it.
Code: (Select All)
'---- The statements below
' While x >= d ' x can be no bigger than d
' x = x - d
' Wend
' While x < 0 ' x can be no less than 0
' x = x + d
' Wend
'---- Can be replaced by
' x = x - int(x / d) * d
' for x = 1.3 and d = .5
Print 1.3 - Int(1.3 / .5) * .5 ' = .3 because int(1.3/.5) = 2 and .3 = 1.3 - 2 * .5
' for x = -.7 and d = .5
Print -.7 - Int(-.7 / .5) * .5 ' = .3 because int(-.7/.5) = -2 and .3 = -.7 - (-2) * .5
___________________________________________________________________________________
I am mostly grateful for the people who came before me. Will the people after me be grateful for me?
I am mostly grateful for the people who came before me. Will the people after me be grateful for me?