ASCII 51
Digit 3 (3)
Printable ASCII
The digit three. ASCII code 51. Because digit codes are contiguous, parsing multi-digit numbers is just value = value * 10 + (c - '0') for each character.
Common uses & context
The character '3' — the digit 3 — has ASCII code 51 (0x33), not 3. This offset of exactly 48 between a digit's glyph and its numeric value is the single most common beginner trap in low-level text handling: the byte that draws '3' on screen is 51, while the number 3 is a different value entirely. The digit three. ASCII code 51. Because digit codes are contiguous, parsing multi-digit numbers is just value = value * 10 + (c - '0') for each character.
The ten digit characters '0'–'9' occupy the contiguous range 48–57, which makes digit handling cheap and branch-free. You can test whether a byte is a digit with c >= '0' && c <= '9', and recover its numeric value with c - '0' (equivalently c - 48). Parsing a whole number is then just value = value * 10 + (c - '0') for each character left to right. For '3', that means c - '0' yields 3.
All encodings at a glance
| Decimal | 51 |
| Hexadecimal | 0x33 |
| Octal | 0063 |
| Binary | 00110011 |
| HTML numeric entity | 3 |
| URL encoding | %33 |
| UTF-8 bytes | 0x33 |
Code snippets
JavaScript
String.fromCharCode(51); // "3"
51.toString(16); // "33"Python
chr(51) # '3'
ord(chr(51)) # 51
hex(51) # '0x33'HTML
3 <!-- numeric entity (no named entity for this character) -->Programming notes
- ▸Character-to-value: '3' - '0' = 3 (i.e. 51 - 48).
- ▸Digit test: c >= '0' && c <= '9' works because 0–9 are the contiguous codes 48–57.
- ▸Multi-digit parse step: value = value * 10 + (c - '0').
Frequently asked questions
What character is ASCII code 51?
ASCII code 51 is the character '3' (Digit 3). In hexadecimal it is 0x33, in octal 0063, and in binary 00110011.
What is 0x33 in ASCII?
Hexadecimal 0x33 equals decimal 51, which is the character '3' (Digit 3). To convert hex to ASCII yourself, read the two hex digits as a base-16 number (0x33 = 51) and look up that code point.
How do I write the character with code 51 in code?
In JavaScript use String.fromCharCode(51); in Python use chr(51); in HTML use the numeric entity 3. In a URL it is percent-encoded as %33, and in UTF-8 it is stored as the byte sequence 0x33.
Why is the digit '3' stored as 51 instead of 3?
Because '3' is a text character, not the number 3. Its ASCII code is 51; the numeric value 3 is separate. Subtract 48 (the code of '0') to convert the character to its value: '3' − '0' = 3.