In real life, our most common numbers are decimal numbers, such as the numbers on traffic lights, the time on electronic watches, etc. If you see 0xAA in these places, it will feel strange. But what do such numbers mean? The following article will introduce it to you, I hope it will be helpful to you.
Data starting with 0x represents hexadecimal. The weight of each bit in the computer is 16, that is (hexadecimal) 10 = (decimal) 1×16 . Note: The 0 here is the number 0, not the letter O!
Hexadecimal (abbreviated as hex or subscript 16) is a carry system that bases 16 on every 16 in mathematics. Generally represented by numbers 0 to 9 and letters A to F (or a~f), where: A~F means 10~15, these are called hexadecimal numbers.
Today’s hexadecimal system is widely used in the computer field because it is not difficult to convert 4 bits into individual hexadecimal numbers. 1 byte can be represented as 2 consecutive hexadecimal numbers. However, this mixed notation is confusing and requires some prefix, suffix, or subscript to display.
How to convert decimal to hexadecimal?
The mathematical calculation method is: use the remainder theorem to decompose, for example, convert 487710 into hexadecimal:
877÷16=304....13(D)
304÷16=19....0
19÷16=1....3
##1÷16=0....1This will count to 487710=130D16You can also use functions in programming, for example: you can use the toString() function in Javascript to convert decimal numbers into other arbitrary base formats (String type) .
The above is the detailed content of What base number starts with 0x?. For more information, please follow other related articles on the PHP Chinese website!