0x

Share

What is 0x?

0x is a code that prefixes a hexadecimal number. For example, 0xFF means the hexadecimal number FF, which in decimal is 255.

This prefix can be found in various programming languages and even in some tools. For example, if you type 0xff in decimal in Google, Google will show you the number 255.

Representing Bytes

Since we can use 2 hexadecimal digits to represent one byte, it's also possible to use this code to represent byte values, e.g. 0x00 to 0xFF are the values from 0 to 255 that we can represent with a single byte. To represent 2 bytes, we would use 0x0000 to 0xFFFF. For 3 bytes, 0x000000 to 0xFFFFFF. 3 bytes is normally used for RGB colors, but those are typically written with an octothorpe (#) instead of a 0x prefix, e.g. #FF0000 for the red color, or 0xFF0000, would mean the same thing as the bits:

1111 1111 0000 0000 0000 0000 

In old 32-bit CPUs, memory addresses could have only 32 bits (4 bytes). Some special memory addresses that looked like words were picked as debugging values, e.g. 0xBAADF00D. This has 8 hexadecimal digits, so it represents 4 bytes. Modern 64-bit CPUs have memory addresses that are twice as long, e.g. 0xBADC0FFEE0DDF00D.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *