Difference between unsigned and signed numbers...

This is a discussion on Difference between unsigned and signed numbers... within the C Programming forums, part of the General Programming Boards category; Hi, What's the difference between unsigned and signed numbers...? thnx...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Difference between unsigned and signed numbers...

    Hi,

    What's the difference between unsigned and signed numbers...?

    thnx

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    8
    unsigned numbers: for positive numbers
    signed numbers: for positive and negative numbers

  3. #3
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    whats the limit of an unsigned integer and signed integer?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    Look in your limits.h file

  5. #5
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    can you tell me how to view .h files?

    thnx

  6. #6
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    #include <stdio.h>
    #include <limits.h>

    int main(void)
    {
    printf("max int = %d\n", INT_MAX);
    printf("max unsigned int = %u\n", UINT_MAX);
    return 0;
    }

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    12
    signed and unsigned represent data type ranges for integers or characters. The limits .h can be found in your compilers help files. It will tell you if the integer is 16 or 32 bit. If it is 16 bit than unsigned int's range is 2^n where n = 16, whereas signed would be approximately half that number because approximately half of the range would be negative.

  8. #8
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    signed bytes: the 7th bit (bytes: 0,1,2,3,4,5,6,7) is 1
    unsigned byte: 7th bit is 0

    This is how (I think) techically (sp?) you sign, unsign bytes. I'm right, right?

    Garfield
    1978 Silver Anniversary Corvette

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    At the bit level, it's a little more sophisticated, but what they basically do is define a signed number so that...
    0x8000 == 0
    0x0000 == INT_MIN
    0xFFFF == INT_MAX

    There are bit-tricks they use to make this work fast, but that's pretty much the idea.
    Callou collei we'll code the way
    Of prime numbers and pings!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 06-04-2009, 02:03 PM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 08:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 06:35 AM
  5. DIfference between signed and unsigned integers ?
    By Nutshell in forum C Programming
    Replies: 7
    Last Post: 01-15-2002, 08:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21