• 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: Corrupted NSMutableString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Corrupted NSMutableString


  • Subject: Re: Corrupted NSMutableString
  • From: Mike Kluev <email@hidden>
  • Date: Sun, 03 Aug 2003 16:05:02 +0400

On 03/08/2003 14:51, Alastair J.Houghton wrote:

> On Sunday, August 3, 2003, at 10:31 am, Mike Kluev wrote:
>
>> On 02/08/2003 21:58, "Alastair J.Houghton" <email@hidden>
>> wrote:
>>
>>> On Saturday, August 2, 2003, at 03:30 pm, Matthew wrote:
>>>
>>>> Since the binary file's definition uses 2-byte short integers (for
>>>> this
>>>> section), I'm kind of stuck. Since C defines short integers as being
>>>> two bytes, it "should" not be a problem.
>>>
>>> No, it doesn't. C defines:
>>>
>>> char is 1 byte
>>
>> I believe it is only specified that "sizeof(char) = 1" and that
>> char should be able to represent the integer number in the range
>> -127 .. +127 (if signed) or 0..+255 (if unsigned). E.g. char can
>> be 20 bits.
>
> Actually the C standard does, as I originally said, defines char in
> terms of the "byte".

C99 in fact does. But it doesn't say "char = byte", rather
it says something like: "char <= byte" ("bit representation
that fits in a byte").

> It also says that a "byte" is at least 8 bits in
> size, is the minimum addressable unit on the machine and can hold any
> member of the basic character set of the execution environment (see
> 3.4, 3.5, 5.2.4.2.1 in the C99 spec). So yes, char can be 20 bits, but
> only if one byte is also 20 bits.

Or larger (see above). And "byte" here is per "execution environment"
so it can be different for two execution environment on a single
computer.

> <rant>
> IMHO it isn't worth fussing about the possibility of char and byte
> being anything other than 8 bits;

Perhaps. If you said "char is usually 1 byte and byte is usually
8 bits" I wouldn't "fuss". But then, *usually* "short" is indeed two
bytes - that was what you were fussing about, so that was my fussing
about fussing :)

> whilst some legacy equipment had
> unusual sizes (like 9 bit bytes), it is highly improbable that anyone
> designing a new machine would even consider bytes of other than 8 bits,
> since such a machine would be incompatible on a fairly fundamental
> level with almost every system operating today. Not to mention the
> fact that it'd give the hardware designers some really unpleasant
> headaches when they tried to use standard off-the-shelf components,
> many of which are set-up for machines with 8-bit bytes.
> </rant>

It is not only about hardware. If so required compiler might
implement 20 bit chars on traditional hardware (not that I say
it is worth to do or that it would be efficient). And again, your
<rant> could be restated and applied to "short integers being
two bytes" :)

Mike
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Corrupted NSMutableString
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >Re: Corrupted NSMutableString (From: "Alastair J.Houghton" <email@hidden>)

  • Prev by Date: Re: [Newbie] mem errors cont.
  • Next by Date: Re: NSTableView Question
  • Previous by thread: Re: Corrupted NSMutableString
  • Next by thread: Re: Corrupted NSMutableString
  • Index(es):
    • Date
    • Thread