I was pulling my hairs for not being able to solve a simple N-body setup until I noticed something strange. I was under the impression that multiplying was done before dividing but not in this case. Am I overlooking something?
Thanks for your help.
Cheers,
Adrian.
int num = 1000;
float radius = 400;
float density = num / PI*sq(radius);
println (density);
Result : 5.092958E7
int num = 1000;
float radius = 400;
float density = num / (PI*sq(radius));
println (density);
// result 0.0019894368
That’s really hard to believe…
If that would be the case, your math in the Netherlands would be broken. I’m from your neighboring country and on equal priority (ie. multiply and divide) it is always left to right.
We learn a frase to remember it “Meneer van Dalen wacht op antwoord”.
m : machtsverheffen (exponentiation)
v : vermenigvuldigen (multiply)
d : delen (devide)
w : worteltrekken (square root)
o : optellen (add)
a : aftrekken (subtract)