Difference between i/10*10 and i?


#1

These are two codes, that should have the exact same result, but don’t… why?

 for (int i = 0; i < vectors.length; i++) {
   vectors[i] = new PVector(i%10*10 + 50, i/10*10); 
 }

 for (int i = 0; i < vectors.length; i++) {
   vectors[i] = new PVector(i%10*10 + 50, i); 
 }

Where is the difference? Can someone explain to me, why the first creates a “cursiv” grid, while the second one a normal one?


#2

#3

try:

for (int i = 0; i < 20; i++) {
  println("i: "+i+" i/10*10: "+(i/10*10));
// or
//  println("i: "+nf(i,2)+" i/10*10: "+nf((i/10*10),2)+" i/10.0*10: "+nf((i/10.0*10),3,1));

}

#4

Well, i actually already set up a grid system with these loops, so i know the different results they produce, but it just didn’t make any sense, thats why i asked :sweat_smile:


#5

Thanks^^ didn’t know it wouldn’t convert that automatically, though now it makes sense :sweat_smile:
Problematic if you don’t know it, but quite useful if you do :blush: