LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Float to HEX and back to float(bytewise)

So you're saying that x7E9F111F is matching the SGL number 12.961126?

I guess then you need to find out how your device is encoding the data. I don't see how these 2 numbers match.

 

In your first post you wrote 

4B

56

A4

FF

 

I don't see the connection.

 

0 Kudos
Message 11 of 30
(3,105 Views)

Hi Dan,

         I think you missed this part of it while reading it.

         NOTE:rough value taken for explanation

        Nevermind...

 

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 12 of 30
(3,071 Views)

Little changes made in vi.

can you tell why im not getting required float value

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 13 of 30
(3,064 Views)

This seems to work.

 

If you allow the hex characters to be converted to an integer, then typecast that to a double.

 

If you read the help for Hexadecimal string to Number, it says

 

"Interprets the characters 0 through 9, A through F, and a through f in string starting at offset as a hex integer and returns it in number.

The connector pane displays the default data types for this polymorphic function.

If you want the function to return a 64-bit integer output, you must wire a 64-bit integer to the default input.

"

 

So I'm thinking that it only converts the hex string to an integer number, even if you wire up a single as the data type, it just converts it to a single float number that is the integer value of those 8 characters (4 bytes).  If so, the help file could probably be a little clearer on this.

 

Message 14 of 30
(3,058 Views)

Nice explanation and thanks for getting it through.

But do have any idea why im not getting required HEX(414F60C6)

instead im getting HEX( 417F67BB) while doing serial VISA read.

 

NOTE:char,integer and long are obtained correct.

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 15 of 30
(3,052 Views)

Still boils down to the same issue: you need to know how your device encodes the data.

But nevermind.

 

Message 16 of 30
(3,049 Views)

 

HIi Dan.Smiley Happy

Im able to get char,int,long value right but float???.

I think for the question i posted i got the ans from you and ravens fan that float value should have been obtained.

finding less problem with hardware as im using ARM architecture.

thank u for sharing knowledge

 

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 17 of 30
(3,043 Views)

GeorgeLiu308_0-1615944559881.png

convert float to hex

 

 

0 Kudos
Message 18 of 30
(1,792 Views)

Hi George,

 

welcome to the LabVIEW forum!

 

What exactly do you want to show with your image?

And why do you think it is a good idea to show just an image of code instead of attaching real code?

(And giving an answer in an 11 years old thread might be fine, bot often the OP is not in the forum anymore…)

 

On your image:

Why is there a blue wire from your SGL input to the TypeCast function?

Why are there so many coercion dots?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 19 of 30
(1,775 Views)

GeorgeLiu308_0-1616011494529.png

 

0 Kudos
Message 20 of 30
(1,749 Views)