Add BitConverter


Converting between byte[] and eg. float is a rather common action in embedded development.
This is also acknowledged by functions such as Microsoft.SPOT.Hardware.Utility.ExtractValueFromArray.
This just needs a few more overloads and be a bit more standardized (Eg. the .net BitConverter).
Closed Jul 16 at 6:57 PM by smaillet_ms
This was added in the 4.3.1 QFE


Illishar wrote Dec 9, 2010 at 9:13 AM

Woops, how do I change the type from "Issue" to "Feature"?

MikeIssa wrote Dec 9, 2010 at 8:28 PM

This is commonly requested. It is on NETMF's road map. See the Documentation page.
GHI added an overload to do float conversion in our library.
Personally, I like the Utility methods more than BitConverter for efficiency reasons. It is very common to convert numbers to byte arrays many times during an application runtime. BitConverter returns a new byte array every time whereas Utility methods can insert into an existing array.

GHI Electronics

Illishar wrote Dec 10, 2010 at 7:39 AM

I agree about the efficiency issue. But the ExtractValueFromArray etc. should at least be moved to the standard BitConverter class and namespace. (For consistency.) And you might also consider renaming the functions so they'll match the existing ones.

Illishar wrote Dec 10, 2010 at 8:11 AM

"It is on NETMF's road map. See the Documentation page."

I can't seem to find it anywhere on the road map. Do you have access to a better version that the one on codeplex?

I see you're assigned to the PWM/Analog issue though. Very nice! I were afraid that GHI would keep to themselves with all the wonderful things you've been creating. PWM is not your best shot though. How about redesigning your RLP to real P/Invokes and then contribute those? ;)

MikeIssa wrote Dec 10, 2010 at 6:21 PM

I see BitConverter at the bottom after the PWM by a couple of lines...


Illishar wrote Dec 13, 2010 at 7:09 AM

Hm, I only see "BitArray" in that area. (System.Collections.BitArray hasn't got anything to do with System.BitConverter. Furthermore I cannot understand why anyone would want to add the BitArray to tinyclr. It doesn't really add anything besides code spam.)

MikeIssa wrote Dec 14, 2010 at 3:40 PM

Oops, I read it wrong.

juliusfriedman wrote Mar 20, 2011 at 7:53 PM

@ Zach, Lorenzo, MSchwarts.

You guys are more then welcome to utilize my BitConverter, which expands upon the ByteReader, ByteWriter done my MSchwartz.


NicolasG wrote Jul 22, 2013 at 8:20 PM

If you want to compile your own solution, the full implementation is available here.