Diffrence in outcome of formula 1.08^12 PHP=13 Visual Basic=2.51817011681898
Feb 22nd, 2008 03:25
dman, Noel Walsh, Winston Chu, http://www.ttnr.org
They differ because the ^ operator is different in each language.
In Visual Basic, ^ means raise the first number to the power of the
second (ie, 2^2=4, or 2 squared, 2^3=8, or 2 cubed), whereas in PHP it
means the bitwise exlusive or of the two numbers.
Bitwise operations only makes sense for integer values, so PHP rounds
the 1.08 to 1 and XORs it with 12. In binary, these are 1 and 1100
respectively, which, when added (xor-ed) gives 1101, or 13.