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 should be 8 bytes = 64 bits.
So 2 exponent (64-1) - 1 = max int size in 64 bit machine.

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.

I don't have 64-bit I have 32-bit.

I use this code to check:

[EMAIL PROTECTED] cp]# cat sizeof.c

#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;
}
[EMAIL PROTECTED] cp]# make sizeof
cc     sizeof.c   -o sizeof

[EMAIL PROTECTED] cp]# ./sizeof
size of a char is 1
size of a short is 2
size of a int is 4
size of a long is 4
size of a float is 4
size of a double is 8
[EMAIL PROTECTED] cp]#
I have a 32-bit PC.

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
[EMAIL PROTECTED]
http://www.gelato.unsw.edu.au


--
O Plameras
http://www.acay.com.au/~oscarp/tutor

--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to