float f;
[myData getBytes:&f length:sizeof(float)];
On Mar 3, 2009, at 9:51 AM, Jay Kickliter wrote:
hat's what I'm doing. But don't understand how to get the 4 bytes I
have in NSData into a float variable.
___
Cocoa-dev mailing list (Cocoa-dev@l
On 3/3/09 11:51 AM, Jay Kickliter said:
>That's what I'm doing. But don't understand how to get the 4 bytes I
>have in NSData into a float variable.
NDData* data = ...
const float* bytes = [data bytes];
float value = bytes[0];
--
Sean
That's what I'm doing. But don't understand how to get the 4 bytes I
have in NSData into a float variable.
On Mar 3, 2009, at 10:39 AM, Sean McBride wrote:
On 3/2/09 8:32 PM, Jay Kickliter said:
I know I have to play around to make sure the bytes are in the right
order. But what I can't see
On 3/3/09 11:00 AM, Michael Ash said:
>It's an unsigned int in the 10.5 SDK, which is what you must use if
>you're going to be using any NS APIs in 64-bit.
So it is, sorry for the noise. (The newest documentation still shows
'long', guess I should have checked the headers too!)
--
_
On Tue, Mar 3, 2009 at 10:43 AM, Sean McBride wrote:
> On 3/3/09 12:42 PM, Graham Cox said:
>
>>Have a look at NSSwapBigFloatToHost and friends
>
> Interesting. I'd not noticed that function, but I'm a bit suspicious of
> it. It takes a NSSwappedFloat struct, which is a struct with a single
> 'l
On 3/3/09 12:42 PM, Graham Cox said:
>Have a look at NSSwapBigFloatToHost and friends
Interesting. I'd not noticed that function, but I'm a bit suspicious of
it. It takes a NSSwappedFloat struct, which is a struct with a single
'long'. But a float is 32 bit, and a long is either 32 or 64 depen
On 3/2/09 8:32 PM, Jay Kickliter said:
>I know I have to play around to make sure the bytes are in the right
>order. But what I can't seem to figure out, is how I create a float
>from those 4 bytes stored in an instance of NSData. Has anybody run
>into this situation?
Not sure if I'm understandin
Just to note. Depending on how many of these you're sending over the
link, I think having an NSData for every 4 byte float is a bit
overkill and could probably end up being a bottle neck. I'm not
saying you should optimize early, but there might be a more straight
forward way of creating
On 03/03/2009, at 12:32 PM, Jay Kickliter wrote:
I have a case where I'm sending IEEE 754 32-bit floats to my Cocoa
program over a wireless serial link, they are being sent MSB first.
I'm using AMSerialPort to handle my data, and after a little
parsing, I'm left with a 4 byte NSData, which
I have a case where I'm sending IEEE 754 32-bit floats to my Cocoa
program over a wireless serial link, they are being sent MSB first.
I'm using AMSerialPort to handle my data, and after a little parsing,
I'm left with a 4 byte NSData, which has the 32-bit float split into 4
bytes.
I know
10 matches
Mail list logo