Results 1 to 5 of 5

Thread: smallest number allowed by my system

Hybrid View

  1. #1
    Join Date
    Aug 2012
    Beans
    623

    smallest number allowed by my system

    Hey,
    I have a couple of questions

    1)Is there any special variable assigned for the smallest and largest possible numbers allowed by my system ? like int.MinValue, int.MaxValue or something of that sort ?

    2)Does it depend on my system alone or does it also depend on my version of gcc ?

    Thanks

    PS : I have a 64 bit system, running gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)
    What's the smallest and largest numbers that I can get ?
    Last edited by IAMTubby; October 4th, 2012 at 12:03 PM.

  2. #2
    Join Date
    Aug 2012
    Beans
    623

    Re: smallest number allowed by my system

    Hey I did this
    Code:
    #include <stdio.h>
    #include <math.h>
    
    int main(void)
    {
     //printf("\nLargest possible number = %u",(unsigned int)((pow(2,(double)((sizeof(unsigned int)) * 8)))));
     printf("\nLargest possible number = %d",(int)((pow(2,(double)((sizeof(unsigned int)) * 8)))));
    
     return 0;
    }

  3. #3
    Join Date
    May 2010
    Beans
    627
    Distro
    Ubuntu Development Release

    Re: smallest number allowed by my system

    Define smallest for us? On the number line, a negative number would be the smallest, but you could be talking about number of decimal points of accuracy.

    In 32 bits:
    Largest unsigned int is (2^32)-1==4294967295
    Smallest unsigned int is 0
    Largest signed int is (2^31)-1==2147483647
    Smallest signed int is -1*(2^31)=-2147483648

    64 bits, just change the math to 64/63 from 32 and 31 respectively.


    Thanks,
    Cipherboy

  4. #4
    Join Date
    Aug 2012
    Beans
    623

    Re: smallest number allowed by my system

    Quote Originally Posted by cipherboy_loc View Post
    Define smallest for us? On the number line, a negative number would be the smallest, but you could be talking about number of decimal points of accuracy.

    In 32 bits:
    Largest unsigned int is (2^32)-1==4294967295
    Smallest unsigned int is 0
    Largest signed int is (2^31)-1==2147483647
    Smallest signed int is -1*(2^31)=-2147483648

    64 bits, just change the math to 64/63 from 32 and 31 respectively.


    Thanks,
    Cipherboy
    Thanks Cipherboy

  5. #5
    Join Date
    May 2008
    Location
    UK
    Beans
    1,451
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: smallest number allowed by my system

    in C there are macros defined for these limits :

    http://en.wikipedia.org/wiki/C_data_...he_basic_types
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •