i defined 2 doubles:
double abc1 = 0.0001; double abc2 = 0.0001;
now if print them:
println "abc1 "+abc1; println "abc2 "+abc2;
it returns:
abc1 1.0e-4 abc2 1.0e-4
while if add them:
println "abc3 "+abc1+abc2;
it returns:
abc3 1.0e-41.0e-4
rather than:
abc3 2.0e-4
why happen?
the reason method didn't work addition operations goes left right. can instead this:
println "answer "+(double)(abc1+abc2);
Comments
Post a Comment