Main Site Documentation

Float <-> byte[]?


#1

I know that this was brought up a few months ago, but it was flagged as “being looked into”.

There is no was to convert a float to a byte array or a byte array to a float.

I’m sending data to the PC over bluetooth and currently I have to convery all my values to string and that is clogging my link, as well as preventing me from using fixed length fields/messages.

converting values to byte arrays is essential when talking to hardware. I know about the GHI function to convert int to byte array, but that is also very easily done with shifting. Float isn’t converted so easily. If if I can just do a mem copy then I will have the four bytes…

Is where any way to get to the underlying storage to read the 4/8 bytes?


#2

http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/0396726b-53ee-4f5b-0b98-a57602a8fb03.htm

Thats what you should use.


#3

Ouch. For some reason I was under the impression that the Util class was for Int32/Int64. I’m sure I saw that on the forum somewhere.

Anyway. Thanks!

Now I can also write floats to my PID co-processor that I want to implement in a PIC18.