Thread: data type for hex

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    21

    data type for hex

    hii everyone..
    i just wanted to know the datatype for hex..how do we declare a hex number like 0x00800000 in C program
    thanx
    cutelucks

  2. #2
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    unsigned int or unsigned long, I'd guess.

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Hexadecimal is just a way to represent a number, as is decimal and binary.

    0x0F == 15 == 00001111

    It's all the same thing. Deep down, the computer treats all numbers as binary, but it doesn't really matter. Numbers are numbers.

    If you want to declare a number in hex, just do it, using any data type that you want.

    Code:
    char c = 0x0A; /* 0x0A = 10 = '\n' */
    Code:
    int x = 0xF0000000; /* Will be taken as a negative number because the sign bit is one.
    				If you declare x as an unsigned variable,
    				then it will be taken as a positive number */

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cutelucks View Post
    how do we declare a hex number like 0x00800000 in C program
    0x00800000

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 10:59 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  5. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM