In C it can be simply done with a cast from float * to char *, but I don't think VB.NET works this way. Do you have an easy way of converting floating(single/double) values to its "byte" form stored?
Requires Free Membership to View
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.
Hannah Smalltree, Editorial DirectorYou can convert many of the intrinsic data types to and from an array of bytes and the actual type using the System.BitConverter class. Specifically look at the GetBytes method, and then the ToDouble and ToSingle methods to convert the byte array back to the appropriate type.
MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A:
This is a very clean and helpful answer. It saved me lots of time. Thanks.
Keith D.
Do you have comments on this Ask the Expert question and response? Let us know.
This was first published in August 2005