DevKits

ASCII 54

Digit 6 (6)

Printable ASCII

The digit six. ASCII code 54. Six is 0b110 in binary; the ASCII byte for the character '6' is 0b00110110, a reminder that the glyph and the value it represents are stored differently.

Common uses & context

The character '6' — the digit 6 — has ASCII code 54 (0x36), not 6. 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 '6' on screen is 54, while the number 6 is a different value entirely. The digit six. ASCII code 54. Six is 0b110 in binary; the ASCII byte for the character '6' is 0b00110110, a reminder that the glyph and the value it represents are stored differently.

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 '6', that means c - '0' yields 6.

All encodings at a glance

Decimal54
Hexadecimal0x36
Octal0066
Binary00110110
HTML numeric entity&#54;
URL encoding%36
UTF-8 bytes0x36

Code snippets

JavaScript

String.fromCharCode(54); // "6"
54.toString(16); // "36"

Python

chr(54)           # '6'
ord(chr(54))      # 54
hex(54)           # '0x36'

HTML

&#54;   <!-- numeric entity (no named entity for this character) -->

Programming notes

  • Character-to-value: '6' - '0' = 6 (i.e. 54 - 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 54?

ASCII code 54 is the character '6' (Digit 6). In hexadecimal it is 0x36, in octal 0066, and in binary 00110110.

What is 0x36 in ASCII?

Hexadecimal 0x36 equals decimal 54, which is the character '6' (Digit 6). To convert hex to ASCII yourself, read the two hex digits as a base-16 number (0x36 = 54) and look up that code point.

How do I write the character with code 54 in code?

In JavaScript use String.fromCharCode(54); in Python use chr(54); in HTML use the numeric entity &#54;. In a URL it is percent-encoded as %36, and in UTF-8 it is stored as the byte sequence 0x36.

Why is the digit '6' stored as 54 instead of 6?

Because '6' is a text character, not the number 6. Its ASCII code is 54; the numeric value 6 is separate. Subtract 48 (the code of '0') to convert the character to its value: '6' − '0' = 6.

Nearby codes

Encode & convert this character