Re: NSData encode decode

2009-04-02 Thread Dave Geering
>> >> IEEE 754 floats always in the same order. >> >> p = 2.71828; >> fprintf (stdout, "%x", *(unsigned long *)&p); >> >> Produces 402df84d on both my PPC and Intel Mac. > > Of course it does. Both long and float use the same byte order within > the same CPU. That's all your test shows. Try doing t

Re: NSData encode decode

2009-04-02 Thread Michael Ash
On Thu, Apr 2, 2009 at 6:58 PM, James Maxwell wrote: > Just a quick update... If I do this: > > const float *markovBytes = (float *)[coder > decodeBytesForKey:@"normalizedMarkovGraph" returnedLength:&mGraphSize]; > [self setNormalizedMarkovGraph:[NSData dataWithBytes:markovBytes > length:mGraphSiz

Re: NSData encode decode

2009-04-02 Thread James Maxwell
Just a quick update... If I do this: const float *markovBytes = (float *)[coder decodeBytesForKey:@"normalizedMarkovGraph" returnedLength:&mGraphSize]; [self setNormalizedMarkovGraph:[NSData dataWithBytes:markovBytes length:mGraphSize]]; it seems to work (it doesn't raise an exception). Don

NSData encode decode

2009-04-02 Thread James Maxwell
I'm having some real trouble with encoding/decoding a 2D float matrix wrapped in an NSData. I'm doing this: - (void)encodeWithCoder:(NSCoder*) coder { NSUInteger mGraphSize = self containerNode] spatialPooler] quantizationCentres] count] * self containerNode