473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Converting C Float value into VB Single data type Help

I'm reading byte information from a C++ program via TCP sockets. At one time
I thought I came across away to convert C Float data type into a VB single
data type. I'm reading the C data type in bytes from the socket stream but
can't seem to convert it. Any help would be greatly appreciated. Here is my
data:

The actual values in the C++ application:
Node 1 LL40
- Position [46.778 - 19.034]

The byte values I'm reading from the C++ socket stream:
-----------Node---------------
(8) 1 Byte
(9) 0 Byte
-----------X Coord------------
This should = 46.778
(10) 172 Byte
(11) 28 Byte
(12) 59 Byte
(13) 66 Byte
-----------y coord------------
This should = 19.034
(14) 162 Byte
(15) 69 Byte
(16) 152 Byte
(17) 65 Byte
------------------------------

Dec 23 '05 #1
2 6247
"Sisnaz" <Si****@discussions.microsoft.com> schrieb
I'm reading byte information from a C++ program via TCP sockets. At
one time I thought I came across away to convert C Float data type
into a VB single data type. I'm reading the C data type in bytes
from the socket stream but can't seem to convert it. Any help would
be greatly appreciated. Here is my data:

The actual values in the C++ application:
Node 1 LL40
- Position [46.778 - 19.034]

The byte values I'm reading from the C++ socket stream:
-----------Node---------------
(8) 1 Byte
(9) 0 Byte
-----------X Coord------------
This should = 46.778
(10) 172 Byte
(11) 28 Byte
(12) 59 Byte
(13) 66 Byte
-----------y coord------------
This should = 19.034
(14) 162 Byte
(15) 69 Byte
(16) 152 Byte
(17) 65 Byte
------------------------------


If it's not possible to read the value as a Single value instead of an array
of bytes, use this:

dim s as single

s= bitconverter.ToSingle(yourByteArray, 10)

Armin

Dec 23 '05 #2
Thank you, thank you, thank you.... That did it!

"Armin Zingler" wrote:
"Sisnaz" <Si****@discussions.microsoft.com> schrieb
I'm reading byte information from a C++ program via TCP sockets. At
one time I thought I came across away to convert C Float data type
into a VB single data type. I'm reading the C data type in bytes
from the socket stream but can't seem to convert it. Any help would
be greatly appreciated. Here is my data:

The actual values in the C++ application:
Node 1 LL40
- Position [46.778 - 19.034]

The byte values I'm reading from the C++ socket stream:
-----------Node---------------
(8) 1 Byte
(9) 0 Byte
-----------X Coord------------
This should = 46.778
(10) 172 Byte
(11) 28 Byte
(12) 59 Byte
(13) 66 Byte
-----------y coord------------
This should = 19.034
(14) 162 Byte
(15) 69 Byte
(16) 152 Byte
(17) 65 Byte
------------------------------


If it's not possible to read the value as a Single value instead of an array
of bytes, use this:

dim s as single

s= bitconverter.ToSingle(yourByteArray, 10)

Armin

Dec 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Goran | last post by:
Hi! I need to convert from a unsigned char array to a float. I don't think i get the right results in the program below. unsigned char array1 = { 0xde, 0xc2, 0x44, 0x23}; //I'm not sure in...
8
by: Rick | last post by:
Hi, Does C have some handy functions to convert chars, ints and floats to bit arrays? I need to store that stuff binary so a few functions would be great. Converting chars and ints isn't...
1
by: Meya-awe | last post by:
Hello there, I am using a 3rd party library and a function which requires a float value in one of its methods. My data is in a string format and i tried using Convert.ToDouble and...
5
by: vivekaseeja | last post by:
Hi , Trying to convert a string value to a float value after reading the value from an XML file , but not sure what function to use. The following only works for integers Int32.Parse...
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
116
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused...
3
by: psbasha | last post by:
Hi , When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ). ...
9
by: ssubbarayan | last post by:
Hi all, I am trying a program to convert floating point values to a byte array and printing the same to the screen.The idea behind this is we already have an existing function which can do byte...
7
by: ma740988 | last post by:
Consider the equation (flight dynamics stuff): Yaw (Degrees) = Azimuth Angle(Radians) * 180 (Degrees) / 3.1415926535897932384626433832795 (Radians) There's a valid reason to use single...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.