Koen van der Drift wrote:

                u_int32_t value;
[base64DecodedData getBytes:&value range:NSMakeRange (n*4, sizeof(u_int32_t))];

                u_int32_t res = CFSwapInt32HostToBig(value);

                float f;

                memcpy(&f, &res, sizeof(f));
                NSLog(@"%f", f);


Since you're just doing a memcpy(), you can simply cast the bits and avoid the copying. Try this:

float f = *((float*) &res);

Or try defining a C union:

union foo {  float f;  u_int32_t u;  };
union foo bar;
bar.u = CFSwapInt32HostToBig(value);
float f = bar.f;

  -- GG

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to