• 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: SInt32 vs int
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SInt32 vs int


  • Subject: Re: SInt32 vs int
  • From: "John C. Daub" <email@hidden>
  • Date: Fri, 02 Jun 2006 06:43:47 -0500
  • Thread-topic: SInt32 vs int

on 6/1/06 10:20 PM, Rick Mann at email@hidden wrote:

> Anwyay, it's signed int. Why is that different from int?

Technically an "int" and a "signed int" are the same thing, just "signed
int" is more explicit.  (this is unlike "char" and "signed char", which
actually are different).

I think it's more about the semantics.

An "int", by the C++ language standard, isn't necessarily 32-bits. All
that's guaranteed is:

1 = sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)

Typically, "int" reflects the natural size of integers on the host machine.
So if you are on a 32-bit system, "int" will be 32-bits; if you're on a
64-bit system, int could be 64-bits.

Now, if all you care about is using an integer and the size of the integer
isn't a factor, then sure, using a raw "int" is probably fine and could be
the more efficient route to go. But if you need to ensure your variable is
of a particular size and behavior (e.g. writing cross-platform code, working
with a binary data format), then using the primitive typedefs are typically
a better way to go.

SInt32 means it is a signed 32-bit integer. Thus, if you use SInt32 you are
guaranteed to have a signed 32-bit integer. If say your code was compiled in
a setup where int was 64-bits, SInt32 would still be 32-bits but would
probably not be typedefed as "signed int" (maybe it would be a "signed short
int"). But what it really is doesn't typically matter; what matters is the
semantics of what the typedef is -- SInt32 means you have a signed 32-bit
integer, however that's implemented.

--
John C. Daub }:-)>=
<mailto:email@hidden> <http://www.hsoi.com/>
"Nothing is greater than love or surrender." -- Buddo


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

This email sent to email@hidden

References: 
 >Re: SInt32 vs int (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Versioning
  • Next by Date: Re: Any way to bind command-option-W to "close all windows"?
  • Previous by thread: Re: SInt32 vs int
  • Next by thread: Xcode 2.2.1 -> 2.3: Intel no longer builds correctly
  • Index(es):
    • Date
    • Thread