Java's Math.Pow() function returning confusing results -


i working math.pow() function, , have following code:

double monthlyrate = (0.7d / 12); int loanlength = 3;  double powertest = math.pow(1.00583, 36); double powerresult = math.pow((1 + monthlyrate),(loanlength * 12)); 

when run through debugger, values become

powertest => 1.2327785029794363 powerresult => 7.698552870922063 

the first correct one. i've stepped math.pow function on both of assignment lines. powertest, parameters math.pow double => 1.00583 double b => 36.0

for powerresult, double => 1.0058333333333333 double b => 36.0

i know issue way floating point math performed machine, i'm not sure how correct it. tried doing following before calculation poor results:

monthlyrate = math.round(monthlyrate * 1000) / 1000; 

1 + monthlyrate 1.0583..., not 1.00583.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -