Home > Ask the Microsoft .Net Development Experts > Visual Basic .NET Questions & Answers > Converting floating values to byte form
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Converting floating values to byte form

Mark Belles EXPERT RESPONSE FROM: Mark Belles

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 08 August 2005
I am designing a program to communicate with another one over the network. I am trying to put single/double values into bytes/buffer (4 or 8 bytes) to transfer over the network. On the other end, the bytes eill be converted back to the floating values.

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?


>

You 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.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
VB.NET
Access VB .NET Windows control on client side
Read data from parallel port
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET
Converting Windows applications to VB .NET
How to add a key to a listview item in VB.NET
Accessing .NET components from VBScript
How I can assign an untyped dataset to a typed dataset?
Last record in the dataset is the only one updating to the database

Visual Basic .NET
Access VB .NET Windows control on client side
Drop down list server control creates error message
Datagrid issue: 'onselection' is not populating
Read data from parallel port
What is the use of these constructors?
Give me an ODBC connect, with SQL authentication
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET
Converting Windows applications to VB .NET

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts