Re: EndianU32_NtoB
Re: EndianU32_NtoB
- Subject: Re: EndianU32_NtoB
- From: "gMail.com" <email@hidden>
- Date: Fri, 30 Oct 2009 18:29:45 +0100
- Thread-topic: EndianU32_NtoB
Cool. Thanks. I did the following, either when I read from the disk and when
I write to the disk
Read unsigned int in case of PPC
outValue[i] = EndianU32_NtoB(inValue[i]);
Write unsigned int in case of PPC
outValue[i] = EndianU32_BtoN(inValue[i]);
Read float in case of PPC
EndianDouble_NtoB(outValue[i], inValue[i]);
Write float in case of PPC
EndianDouble_BtoN(outValue[i], inValue[i]);
where:
#define EndianDouble_BtoN(o,i)
((Float64*)&o)[0]=CFConvertFloat64SwappedToHost(((CFSwappedFloat64*)&i)[0]);
#define EndianDouble_NtoB(o,i)
((CFSwappedFloat64*)&o)[0]=CFConvertFloat64HostToSwapped(((Float64*)&i)[0]);
Please note, I read/write the array from/to an NSData
[data getBytes:inArray length:dataLength];
// then I convert
// firstly I convert then...
data = [NSData dataWithBytes:outArray length:dataLength];
Is that correct?
--
Leonardo
> Da: Jens Alfke <email@hidden>
> Data: Fri, 30 Oct 2009 09:15:50 -0700
> A: "gMail.com" <email@hidden>
> Cc: <email@hidden>
> Oggetto: Re: EndianU32_NtoB
>
>
> On Oct 30, 2009, at 8:56 AM, gMail.com wrote:
>
>> In the past I have successfully used EndianU32_NtoB to read a "long"
>> on a
>> PPC machine. Now I need to read and write an array of "unsigned int"
>> and an
>> array of "float". May you please tell me how to do?
>
> Just write a 'for' loop to convert each element of the array; either
> in place or copying into a new array.
>
> Jens
>
> PS: Could you please use a name other than "gMail.com"? That's pretty
> confusing.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden