问题
I was reading the PHP documentation on Integers, where it's specifies the different ways in which you can specify which notation to use. Here's a snippet of the doc for anyone interested.
<?php
$a = 1234; // decimal number
$a = -123; // a negative number
$a = 0123; // octal number (equivalent to 83 decimal)
$a = 0x1A; // hexadecimal number (equivalent to 26 decimal)
$a = 0b11111111; // binary number (equivalent to 255 decimal)
?>
However, in PHP (and even some other programming languages where applicable), why would you ever choose to write in Octal, Hexadecimal, or Binary notation over Standard Notation (base 10). Doesn't this just make the numbers more difficult to read for other programmers?
Is there a physical boost in performance in any way by using one notation over another? Is it counter intuitive if you have to change the notation later to be readable by users? E.g. Record users age in Hexadecimal but display it in standard.
来源:https://stackoverflow.com/questions/47199335/why-would-you-write-in-octal-hexadecimal-binary-over-standard-notation