Why is 14%11 returning 2


I am currently trying to start using Custom Nodes to do different stuffs, to try learning the base I’ve attempted to do a pixelized effect with a for loop.

The problem is that in my for loop, I use i%Tiling(which is 11 from Input) but 13%11 and 14%11 returns the same square, and then 15 jumped the space 14 should have taken, leaving an empty square. 14 isn’t the only one which has problem, on the picture below all black square (except the top left one) are empty space due to 2 number giving the same result, I tried with different tilings, from 1 to 4 it’s fine, but starting to 5 there are some problems.

I’m trying to figure it out but the math are pretty simple, it’s just a modulus. Am I missing something?

Thank you!

It might be related to fact that “Tiling” is a float do float inaccuracy is hitting in, try tret it with Trunc

Hey :stuck_out_tongue:

Yes strangely after playing with it you were right!

In fact there’s a weird thing happening, I’ve added a section where I decide the color. The color needs to use a float, and the UV need to use a Int. Even though the number is 11 and shouldn’t make a difference.

Also, the problem is only there if in a loop, because if I set i to 14 (commented in the original picture) it works…

Also, I’ve noticed that power of 2 numbers works better.

So the problem is found, but I still don’t understand why :confused:

Yes make sure to cast to int or Truncate before using modulus