Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3670634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:23:22+00:00 2026-05-19T02:23:22+00:00

Why are hexadecimal numbers prefixed as 0x ? I understand the usage of the

  • 0

Why are hexadecimal numbers prefixed as 0x?
I understand the usage of the prefix but I don’t understand the significance of why 0x was chosen.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:23:22+00:00Added an answer on May 19, 2026 at 2:23 am

    Short story: The 0 tells the parser it’s dealing with a constant (and not an identifier/reserved word). Something is still needed to specify the number base: the x is an arbitrary choice.

    Long story: In the 60’s, the prevalent programming number systems were decimal and octal — mainframes had 12, 18, 24 or 36 bits per byte, which is nicely divisible by 3 = log2(8).

    The BCPL language used the syntax 8 1234 for octal numbers. When Ken Thompson created B from BCPL, he used the 0 prefix instead. This is great because

    1. an integer constant now always consists of a single token,
    2. the parser can still tell right away it’s got a constant,
    3. the parser can immediately tell the base (0 is the same in both bases),
    4. it’s mathematically sane (00005 == 05), and
    5. no precious special characters are needed (as in #123).

    When C was created from B, the need for hexadecimal numbers arose (the PDP-11 had 16-bit words and 8-bit bytes) and all of the points above were still valid. Since octals were still needed for other machines, 0x was arbitrarily chosen (00 or 0h was probably ruled out as awkward).

    C# is a descendant of C, so it inherits the syntax.

    You can find details about the history of C at Dennis M. Ritchie’s page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that 0x is a prefix for hexadecimal numbers in Javascript. For example,
I need to do some arithmetic with large hexadecimal numbers below, but when I
I've googled this but possibly typing in the wrong thing. I see hexadecimal numbers
What I understand that hexadecimal numbers can be placed into string using \x .
I'm trying to extract packed hexadecimal numbers from a string. My application is communicating
I have some code which takes strings representing hexadecimal numbers - hex colors, actually
How do I create a regular expression that detects hexadecimal numbers in a text?
I have noticed that PHP and JavaScript treat octal and hexadecimal numbers with some
I want to generate unique hexadecimal numbers in SQL. How can I do this?
How to swap the following two hexadecimal numbers in c language? Eg: input :0xabcd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.