Thread: Hexadecimal constants

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    6

    Hexadecimal constants

    What's a hexadecimal constant, and should I bother learning? Are there situations were I need to know it or can I always use some other way?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >What's a hexadecimal constant
    A hexadecimal constant is the same thing as a decimal constant except using a different numbering system. For example:

    int i = 27;
    and
    int j = 0x1B;

    Are both equivalent. The only difference is what numbering system you used for the constant, if you asked for the decimal value of j then you would still get 27. Hexadecimal constants must being with 0x (zero + x) and octal constants must begin with 0 (zero).

    >Are there situations were I need to know it or can I always use some other way?
    Regardless of whether or not you use hexadecimal in your programs, it's good to at least know how other number systems work. The most important to programmers are binary, octal, decimal, and hexadecimal.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 12-02-2007, 05:55 AM
  2. COnstants
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 09-01-2007, 04:59 AM
  3. would you explain to me? hexadecimal to decimal
    By shteo83 in forum C Programming
    Replies: 2
    Last Post: 02-25-2006, 03:55 PM
  4. Help with Constants and enum constants. Newbie learning C++.
    By UnregJDiPerla in forum C++ Programming
    Replies: 5
    Last Post: 01-07-2003, 08:29 PM
  5. decimal to binary, decimal to hexadecimal and vice versa
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 12-08-2001, 11:07 PM