I want to get the fraction (modulo 1) of the quotient of two long values.
long dividend = 50L;
long divisor = 3L;
float n1 = (dividend % divisor) / (float) divisor;
float n2 = (dividend / (float) divisor) % 1;
System.out.println(n1);
System.out.println(n2);
The above prints the following.
0.6666667
0.66666603
I don't have very good knowledge of how floating point precision works.
Why is the second (probably clearer) implementation less accurate than the first?