Bug? x + y mod x ? [SOLVED]

ilan

Expert
Licensed User
Longtime User
hi

i dont know if it is a bug but it seems to me to be one.

if i use before the MOD function a calculation without () i get a different result then if i would use ()

like this code here:

B4X:
    For i = 0 To 7
        Dim num As Int = i + 2 Mod 7
        Log(num)
    Next

Waiting for debugger to connect...
Program started.
2
3
4
5
6
7
8
9

but this is correct:

B4X:
    For i = 0 To 7
        Dim num As Int = (i + 2) Mod 7
        Log(num)
    Next

Waiting for debugger to connect...
Program started.
2
3
4
5
6
0
1
2

hmmm...

what i understand is that MOD comes before +/- so the calculation looks now like this: i + (2 mod 7) but it doesnot make sense when we use mod in coding. or am i wrong?
 
Top