unsigned long long int with os-x

Nicholas Strauss nicks@carriage.chesco.com
Sun Oct 13 17:11:00 GMT 2002


Hi Segher,
Yes, this works on Macintosh OS-X.
u: 9223372036854775808
u--: 9223372036854775807
u++: 9223372036854775809
2u: 0
thanks,
Nick
On Sunday, October 13, 2002, at 08:04 PM, Segher Boessenkool wrote:

> Nicholas Strauss wrote:
>>
>> Hi,
>>
>> I'm trying to use gcc in darwin os-x. I've written the following 
>> piece of code:
>>
>> int main(int argc, char *argv[])
>> {
>> unsigned long long int u;
>>
>> u = 1<<63;
>
> This is the int 1 shifted by 63 bits to the left; that's "undefined 
> behaviour"
> by the C standard (and will probably result in 0).
>
> Write
>
> 	u = 1LL << 63;
>
> instead.
>
>> printf("u: %ld uu: %ld\n", u, u-1);
>> printf("maxint %ld\n", INT64_MAX);
>> }
>>
>> What compiler/linker options should I use with gcc?
>
> No special options are needed.  But try out -Wall and -W.
>
>> What format should I use with printf?
>
> "%lld" if I remember correctly.
>
>
> Have fun,
>
> Segher
>



More information about the Gcc-help mailing list