ASCII 48
Digit 0 (0)
Printable ASCII
The digit zero. Its ASCII code is 48, not 0 — a classic bug source when you forget that '0' (char) and 0 (number) differ by 48. Convert a digit char to its value with c - '0'. In C-family strings, '\0' (code 0) terminates a string, which is a different character entirely.
Common uses & context
The character '0' — the digit 0 — has ASCII code 48 (0x30), not 0. 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 '0' on screen is 48, while the number 0 is a different value entirely. The digit zero. Its ASCII code is 48, not 0 — a classic bug source when you forget that '0' (char) and 0 (number) differ by 48. Convert a digit char to its value with c - '0'. In C-family strings, '\0' (code 0) terminates a string, which is a different character entirely.
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 '0', that means c - '0' yields 0.
All encodings at a glance
| Decimal | 48 |
| Hexadecimal | 0x30 |
| Octal | 0060 |
| Binary | 00110000 |
| HTML numeric entity | 0 |
| URL encoding | %30 |
| UTF-8 bytes | 0x30 |
Code snippets
JavaScript
String.fromCharCode(48); // "0"
48.toString(16); // "30"Python
chr(48) # '0'
ord(chr(48)) # 48
hex(48) # '0x30'HTML
0 <!-- numeric entity (no named entity for this character) -->Programming notes
- ▸Character-to-value: '0' - '0' = 0 (i.e. 48 - 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 48?
ASCII code 48 is the character '0' (Digit 0). In hexadecimal it is 0x30, in octal 0060, and in binary 00110000.
What is 0x30 in ASCII?
Hexadecimal 0x30 equals decimal 48, which is the character '0' (Digit 0). To convert hex to ASCII yourself, read the two hex digits as a base-16 number (0x30 = 48) and look up that code point.
How do I write the character with code 48 in code?
In JavaScript use String.fromCharCode(48); in Python use chr(48); in HTML use the numeric entity 0. In a URL it is percent-encoded as %30, and in UTF-8 it is stored as the byte sequence 0x30.
Why is the digit '0' stored as 48 instead of 0?
Because '0' is a text character, not the number 0. Its ASCII code is 48; the numeric value 0 is separate. Subtract 48 (the code of '0') to convert the character to its value: '0' − '0' = 0.