ASCII 0 Character (Digit Zero)
The digit 0 (zero) has ASCII code 48 and represents the numeric digit zero. It's fundamental in programming for numeric processing, string-to-number conversions, and mathematical operations.
Digit Zero
0
ASCII Code: 48 | Hex: 30 | Binary: 0110000
⚠️ Important Distinction
Digit '0' (ASCII 48) is different from NULL character (ASCII 0):
- Digit '0': ASCII 48, represents the numeric digit zero
- NULL: ASCII 0, a control character used to terminate strings
Character Information
| Property | Value |
|---|---|
| ASCII Code (Decimal) | 48 |
| ASCII Code (Hexadecimal) | 30 |
| ASCII Code (Binary) | 0110000 |
| Unicode | U+0030 |
| HTML Entity | 0 or 0 |
| Character Type | Digit, Numeric |
| Numeric Value | 0 |
ASCII Digits Range (0-9)
| Digit | ASCII Code | Hex | Digit | ASCII Code | Hex |
|---|---|---|---|---|---|
| 0 | 48 | 30 | 5 | 53 | 35 |
| 1 | 49 | 31 | 6 | 54 | 36 |
| 2 | 50 | 32 | 7 | 55 | 37 |
| 3 | 51 | 33 | 8 | 56 | 38 |
| 4 | 52 | 34 | 9 | 57 | 39 |
Click any digit to copy it to clipboard
Programming Examples
JavaScript
// Character literal
let digitZero = '0';
let fromCode = String.fromCharCode(48); // From ASCII code
let fromHex = '\x30'; // Hexadecimal escape
// Convert ASCII digit to number
let numericValue = '0'.charCodeAt(0) - 48; // Returns 0
let parsed = parseInt('0'); // Returns 0
let isDigit = '0' >= '0' && '0' <= '9'; // true
let digitZero = '0';
let fromCode = String.fromCharCode(48); // From ASCII code
let fromHex = '\x30'; // Hexadecimal escape
// Convert ASCII digit to number
let numericValue = '0'.charCodeAt(0) - 48; // Returns 0
let parsed = parseInt('0'); // Returns 0
let isDigit = '0' >= '0' && '0' <= '9'; // true
Python
# Character literal
digit_zero = '0'
from_code = chr(48) # From ASCII code
from_hex = '\x30' # Hexadecimal escape
# Convert ASCII digit to number
numeric_value = ord('0') - 48 # Returns 0
parsed = int('0') # Returns 0
is_digit = '0'.isdigit() # Returns True
digit_zero = '0'
from_code = chr(48) # From ASCII code
from_hex = '\x30' # Hexadecimal escape
# Convert ASCII digit to number
numeric_value = ord('0') - 48 # Returns 0
parsed = int('0') # Returns 0
is_digit = '0'.isdigit() # Returns True
C/C++
// Character literal
char digit_zero = '0';
char from_code = 48; // From ASCII code
char from_hex = '\x30'; // Hexadecimal escape
// Convert ASCII digit to number
int numeric_value = '0' - '0'; // Returns 0
int parsed = atoi("0"); // Returns 0
bool is_digit = isdigit('0'); // Returns true
char digit_zero = '0';
char from_code = 48; // From ASCII code
char from_hex = '\x30'; // Hexadecimal escape
// Convert ASCII digit to number
int numeric_value = '0' - '0'; // Returns 0
int parsed = atoi("0"); // Returns 0
bool is_digit = isdigit('0'); // Returns true
ASCII to Number Conversion
Converting ASCII digits to their numeric values is a common programming task:
Conversion Formula
Numeric Value = ASCII Code - 48
- '0' (ASCII 48) → 48 - 48 = 0
- '1' (ASCII 49) → 49 - 48 = 1
- '2' (ASCII 50) → 50 - 48 = 2
- ... and so on for digits 0-9
Common Uses
- Numeric Input: Processing user input containing numbers
- String Parsing: Converting string representations to numbers
- Data Validation: Checking if characters are valid digits
- Mathematical Operations: Base for all numeric calculations
- Leading Zeros: Formatting numbers with leading zeros
- Binary/Octal/Hex: Base digit in various number systems
- Counters and Indices: Starting point for many counting operations