where does 0x come from? [duplicate]

萝らか妹 提交于 2019-12-06 02:31:29

问题


Possible Duplicate:
Why are Hexadecimal Prefixed as 0x?

I just saw a comment a friend of mine made:

3x12=36
2x12=24
1x12=12
0x12=18

Which made me wonder..
Why did they choose 0x as prefix for hexadecimal numbers? Is there any history behind this decision?


回答1:


I think, because x comes from hex and 0 is to indicate that it is a number.




回答2:


0x means the number is probably hexadecimal. This applies in C/C++, and probalby other languages.

His comment is a joke. he starts with multiplication tables for the number 12, but when he gets to 0 he implies that 0x is not "0 multiplied by...", but instead is "hexadecimal" so 12 in hex is 18 in decimal.




回答3:


It's a joke on HEX numbers from WIKIPEDIA.

The first three are interpreted as multiplication, but in the last, "0x" signals Hexadecimal interpretation of 12, which is 18.




回答4:


'0x' means that the number that follows is in hexadecimal. It's a way of unambiguously stating that a number is in hex, and is a notation recognised by C compilers and some assemblers



来源:https://stackoverflow.com/questions/4257661/where-does-0x-come-from

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