Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Your top-ten linux desktop apps


felix@quokka64 ~/Desktop $ gcc sizeof.c
felix@quokka64 ~/Desktop $ ./a.out
size of a char is 1
size of a short is 2
size of a int is 4
size of a long is 8
size of a float is 4
size of a double is 8


O Plameras wrote:


Does anybody have a 64-bit computer ?

Are you able to compile and run the following code and publish the results ?

Thanks.

#include <stdio.h>

int main(void)
{
      printf("size of a char is %d\n", sizeof(char));
      printf("size of a short is %d\n", sizeof(short));
      printf("size of a int is %d\n", sizeof(int));
      printf("size of a long is %d\n", sizeof(long));
      printf("size of a float is %d\n", sizeof(float));
      printf("size of a double is %d\n", sizeof(double));
      return 0;
}


Ian Wienand wrote:

On Thu, Sep 29, 2005 at 07:39:51PM +1000, O Plameras wrote:
With C on 64-bit your number will not be a problem as an integer. C
integer is size 8 bytes = 64 bits. So 2 exponent 64 less 1 can be
handled.


This isn't correct; there are two main models for 64 bit computing.
LP64 where longs and pointers are 64 bits (Linux, most UNIX?) and the
Windows model where only pointers are 64 bits.  Many might suggest
this is because so much Windows code would break if long suddenly
became 64 bits, but I think the official reason is efficiency within
the API.

In both cases an int is 32 bits.  In both models a long long will be
64 bits, no matter what your architecture.  It's no wonder people use
Python/Perl/OCaml/Haskell/Smalltalk so they don't have to worry about
any of this.

-i
ianw@xxxxxxxxxxxxxxxxxx
http://www.gelato.unsw.edu.au