Basic Question help

This is a discussion on Basic Question help within the C Programming forums, part of the General Programming Boards category; I do not want the answer, i would like to do them on my own i would just like some ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Location
    Texas
    Posts
    10

    Question Basic Question help

    I do not want the answer, i would like to do them on my own i would just like some help in where to start...

    What are the minimum and maximum values for an integer with n bits in signed representation. what is the maximum value for an integer with n bits in unsigned representation : Express these values in both decimal and binary representation. For a negative value in binary, use binary two's complement representation.
    (a) n is 8. (b) n is 16 (c) n is 32 (d) n is 6 (e) n is 10.

    i know ill prolly be using <limits.h>

    and from what i read and understand its something along these lines

    printf("INT_MAX = %d\N", INT_MAX);

    printf("INT_MIN = %d\N", INT_MIN);

    printf("UINT_MAX = %u\N", UINT_MAX);

    but isnt that just for int which = 4 how would i do the others?
    Last edited by Salem; 09-24-2010 at 12:55 AM. Reason: Restore original post

  2. #2
    Registered User
    Join Date
    Sep 2010
    Location
    Texas
    Posts
    10
    please delete

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,245
    There are similar macros - with different names - in <limits.h> for other integral types (char, short, long, unsigned short, etc).

    Incidentally, there is no requirement that int has size of 4. That is compiler dependent (aka "implementation defined" in the standards)
    Right 98% of the time, and don't care about the other 3%.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    Please don't edit your post down to nothing and bugger off as soon as you've got your answer.

    The whole purpose of the forum is for people to learn from what has been said and answered. If you remove your posts, then that makes grumpy's answer meaningless and a waste of effort.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A basic math programming question
    By hebali in forum C Programming
    Replies: 38
    Last Post: 02-25-2008, 03:18 PM
  2. Basic question about GSL ODE func RK4
    By cosmich in forum Game Programming
    Replies: 1
    Last Post: 05-07-2007, 02:27 AM
  3. Basic question about RK4
    By cosmich in forum C++ Programming
    Replies: 0
    Last Post: 05-07-2007, 02:24 AM
  4. A very basic question
    By AshFooYoung in forum C Programming
    Replies: 8
    Last Post: 10-07-2001, 03:37 PM

Tags for this Thread


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