G
Guest
I do not know how to convert from a byte array to a float, and back again. I
read data from a serial port into a byte[] (entire command structure which I
parse). I am able to sift the data and isolate the information I want, in
this case a structure that contains a bunch of floats and longs.
So, lets say I have a byte[] containing the 4 bytes of info that are
actually a float. In old C code, I would simple declare a pointer to the
correct location in the array and call it a pointer to a float. Make sense?
How do I do this with C#? I know how to go between a float and a text box,
that's simple. But how to switch between the byte array and a float? I see
how to do a single byte, but not a byte array. This same problem involves
converting between longs and byte[].
I hope there is a simple way to do this. With pointers and C, it's a piece
of cake. Just need a little help with C#.
read data from a serial port into a byte[] (entire command structure which I
parse). I am able to sift the data and isolate the information I want, in
this case a structure that contains a bunch of floats and longs.
So, lets say I have a byte[] containing the 4 bytes of info that are
actually a float. In old C code, I would simple declare a pointer to the
correct location in the array and call it a pointer to a float. Make sense?
How do I do this with C#? I know how to go between a float and a text box,
that's simple. But how to switch between the byte array and a float? I see
how to do a single byte, but not a byte array. This same problem involves
converting between longs and byte[].
I hope there is a simple way to do this. With pointers and C, it's a piece
of cake. Just need a little help with C#.