Do Parenthesis Enforce Execution Order?

Greetings -

I have large CSV datasets with periodic time stamps (integer accumulated seconds) scattered through the records. I want to process the data in time blocks, say block = 60 seconds.

I am used to doing in C and pretty sure formerly in RB/Xojo if ( ( sec\N) * N =sec) then … I find that that does not work in 2019R3.1 and I have to use mod, instead, Fortunately mod works, but this raises the question of whether or not parenthesis enforce execution order. It is looking very much like the multiplication by N and the integer division by N are optimized away, leaving a test that is true for every value of “sec”.

Many thanks
Jim Wagner
Oregon Research Electronics

I don’t see this in windows. Are you able to put a small sample of code together with comments where you expect things showing this problem so we can see where the error might be?

Thanks for checking Julian. I just tried on MacOS (Mojave)

var N as integer = 5
var K as integer = (23\N) * N

and it worked correctly. There must have been something else that was originally incorrect. Same compiler.

Jim

Are you sure you used \ and not / when it didn’t work? Because that would explain what you saw.

Norman says:

Xojo sometimes does not infer correctly the expression context as you would expect and instead of using all intermediate values as integer sometimes promotes values to intermediate larger floating point with residual fractions avoiding equality (like when you expect 0 but internally it is 0.000000000000003). Not sure if this case. But to compare x = y, the best way is storing the calculated values and compare after as you did here: