Hi!
Can some one explain why result ‘-1299’ is shown after executing following statment.
$var = 1 + "-1.3e3";
var_dump($var);
Thanks in advance
Hi!
Can some one explain why result ‘-1299’ is shown after executing following statment.
$var = 1 + "-1.3e3";
var_dump($var);
Thanks in advance
What did you expect it to show? The explanation is 1 - 1300 = -1299
Already answered, but out of curiosity, what are you wanting to occur instead?
Thanks for reply. My confuion is how “1.3e3” is actually 1300.
Does expanding it out to 1.3 * 10^3 help?
A bit of a study of http://en.wikipedia.org/wiki/Scientific_notation#E_notation might help too.
Scientific notation, it actually reads as 1.3 x 10 ^ 3. PHP recognizes this as a number when casting from a string.
Really thanks for your help.