public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nicholas Strauss <nicks@carriage.chesco.com>
To: Segher Boessenkool <segher@koffie.nl>
Cc: gcc-help@gcc.gnu.org, Nicholas Strauss <ncs@alum.mit.edu>
Subject: Re: unsigned long long int with os-x
Date: Sun, 13 Oct 2002 17:11:00 -0000	[thread overview]
Message-ID: <C323A51E-DF08-11D6-9BA5-000393AC01F6@carriage.chesco.com> (raw)
In-Reply-To: <3DAA0A1A.CAEECF78@koffie.nl>

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
>

      reply	other threads:[~2002-10-14  0:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-13  7:59 Nicholas Strauss
2002-10-13 17:06 ` Segher Boessenkool
2002-10-13 17:11   ` Nicholas Strauss [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C323A51E-DF08-11D6-9BA5-000393AC01F6@carriage.chesco.com \
    --to=nicks@carriage.chesco.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=ncs@alum.mit.edu \
    --cc=segher@koffie.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).