PHP bizarre math

Richlad

New Member
I'm getting unexpected values for variable calculations:\[code\]$var1 = $var2 * (((1 + $var3)^$var4)^$var5);\[/code\]I've verified that \[code\]$var2\[/code\] is 3, \[code\]$var3\[/code\] is 0.1, \[code\]$var4\[/code\] is 1, \[code\]$var5\[/code\] is 1.1 so,\[code\]$var1 = 3*(((1+0.1)^1)^1.1) = 3.3316\[/code\] but in PHP, \[code\]$var1 = 3\[/code\]if I change \[code\]$var4\[/code\] to 2,\[code\]$var1 = 3*(((1+0.1)^1)^1.1) = 3.6999\[/code\] but in PHP, \[code\]$var1 = 6\[/code\]Why is this? Any ideas? I've tried explicitly declaring all variables as floats.
 
Back
Top