LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

real to word conversion

Hello,

I need to convert a real number (single-32 bits) to words, I mean to split the real 32b into 2 of 16 bits.
I have tried the conversions VIs but then I lose the decimals. The precision of the real (number of decimals) is variable.
Thanks for any suggestion about!

SBC
0 Kudos
Message 1 of 6
(3,133 Views)
Do you mean take a 32 bit IEEE floating point number and split it into two 16 bit words?

Look at the Advanced >> Data Manipulation functions Flatten to String and Unflatten from String and the Numeric >> Conversion function String to Byte Array.

See the attached LV 6.1 example.
0 Kudos
Message 2 of 6
(3,133 Views)
> I need to convert a real number (single-32 bits) to words, I mean to
> split the real 32b into 2 of 16 bits.
> I have tried the conversions VIs but then I lose the decimals. The
> precision of the real (number of decimals) is variable.
> Thanks for any suggestion about!
>

Try looking in the Advanced palette. There is a Split Words node that
does what you want. It is normally used on integers, but might work on
floats as it. If not, first use TypeCast, not conversion, but type cast
to make it be treated as an integer, then use the word splitter.

Greg McKaskle
0 Kudos
Message 3 of 6
(3,133 Views)
Thanks!I have tried your suggestions and both of them works. It's just what I needed. Thanks for the FlattenNumberVI. The split words node doesn't works with singles, but it does using type cast.
See you,

SBC
0 Kudos
Message 4 of 6
(3,133 Views)
Neat approach! Depending on what the user needed to do with the 16 bit words, this may save a step or two over my way of Flatten to String and String to Byte Array.

On a related note, I've had intermittent problems using the Join Numbers function (the converse (?) of Split Number). As a small part of a much larger test, I join a pair of 16-bit numbers. Intermittently, even on simple joins (e.g. hi=0, lo=4), I get a huge and bogus number. I have stopped using Join Numbers in that application (Windows 98, LabView 5.1) and just multiply and add. I don't have enough time on our latest configuration (Windows 2000, LabView 6.1) to know if anything's changed.
0 Kudos
Message 5 of 6
(3,133 Views)
Also check out Scott Menjoulet's sample here:

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000D5660000&USEARCHCONTEXT_CATEGORY_0=_49_%24_6_&USEARCHCONTEXT_CATEGORY_S=0&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0
0 Kudos
Message 6 of 6
(3,133 Views)