Why would you write in Octal/Hexadecimal/Binary over Standard Notation?

一曲冷凌霜 提交于 2019-12-08 02:50:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!