related to php arithmetic -
$y = 013; echo $y + 5; //this result in 16 i can not figure out how ans 16? can 1 help?
because 013 isn't decimal (base 10). it's octal (base 8). value in decimal is: (0 * 8^2) + (1 * 8^1) + (3 * 8^0) = 0 + 8 + 3 = 11
which gives correct (though unexpected, @ least you) result of 16 when added 5.
moral of story: don't prepend number literal 0 unless know means
Comments
Post a Comment