+ Start a Discussion

APEX - Number Rounding?

I have two fields defined on a custom object:

N1 : Currency(3, 8)
N2 : Number(2, 0)

Using APEX, I query for this record and place into a variable named 'rec'.
Then, I use debug to print out these values to the console:

Here is what it prints out:
rec.N1 = 125.0
rec.N2 = 12.0

Then, I try to divide the two numbers:
Double N3 = rec.N1 / rec.N2;

When i print out N3, it displays:
N3 = 10.4

However, If I assign N3 = 125.0/12.0 and print out N3 again, i get:
N3 = 10.416666666666666 ( Which is the correct value... not 10.4 )

Why is APEX truncating/rounding the first value to 10.4?