I'm getting unexpected values for variable calculations:
$var1 = $var2 * (((1 + $var3)^$var4)^$var5);
I've verified that $var2
is 3, $var3
is 0.1, $var4
is 1, $var5
is 1.1 so,
$var1 = 3*(((1+0.1)^1)^1.1) = 3.3316
but in PHP, $var1 = 3
if I change $var4
to 2,
$var1 = 3*(((1+0.1)^1)^1.1) = 3.6999
but in PHP, $var1 = 6
Why is this? Any ideas? I've tried explicitly declaring all variables as floats.
Note that ^
is not "power of". You may want to have a look at the pow function.
(^
is actually "bitwise exclusive or".)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With