• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: SInt64 and UInt64 problems with large values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SInt64 and UInt64 problems with large values


  • Subject: Re: SInt64 and UInt64 problems with large values
  • From: Segher Boessenkool <email@hidden>
  • Date: Mon, 4 Apr 2005 10:45:26 +0200

In lieu of using "long long" and "unsigned long long" in my code, I'm trying to use the more compact "SInt64" and "UInt64" both of which the compiler seems to be aware of , but when I try to give UInt64 a large constant hex value such as 0xFFFFFFFFFFFFFFFF, the complier complains that "integer constant is too large for "long" type." I searched for the definition of UInt64 and found it in MacTypes.h where it is defined as "typedef unsigned long long UInt64" so why does the compiler not allow the maximum hex value? Is there some undocumented upper limit to long long values?

Check the compiler support for big constants. By default, these constants are integers (the compiler, at the time the constant is interepreted, does not and cannot know you will store it into a long or even long long), and thus self-evidently too big.

Of course it is an integer -- although I think you meant 'int'.

GCC is by default in C90 mode; integer constants of higher precision
than 'long' need a suffix then -- they do not in C99 mode.

You'll have to use some suffix, like 0xFF...FFull (or something), to let the compiler know the constant is long long AND unsigned, too. At the moment, I don't recall the proper suffix though, sorry.

You remembered correctly, it is 'ull' (or 'ULL' or 'llU' or...). For hexadecimal constants, you do not need to specify the 'U' though, just the 'LL' is enough.


Segher

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >SInt64 and UInt64 problems with large values (From: Ken Tozier <email@hidden>)
 >Re: SInt64 and UInt64 problems with large values (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: ANN: VMTester - virtual memory testing utility
  • Next by Date: Re: WWDC 2005 - Is the value worth the price? (OT)
  • Previous by thread: Re: SInt64 and UInt64 problems with large values
  • Next by thread: Re: SInt64 and UInt64 problems with large values
  • Index(es):
    • Date
    • Thread