LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How Type cast works in detail

Hii
 
  Can any one help me i want to know how Type cast function is working
0 Kudos
Message 1 of 5
(3,300 Views)
Hi Karthikey,

typecasting means:
take the actual data (internally represented by some bits!) and re-interprete exactly those bits using a different datatype. The bits will stay the same, it's just a different interpretation!

Example:
Array of 2 U8 values like [0x41],[0x42] -> typecasting to string -> "AB"
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,292 Views)
Plz explain me with example in detail
0 Kudos
Message 3 of 5
(3,282 Views)
Say you have a string that says "Hello World!" and that the bit representation in memory of that is 010011010110101101010010 (which isn't right at all, but it's an example).  If you typecasted that to an I32 (a signed, 32 bit integer), it would read the zeros and ones as though it was a 32 bit signed integer, and be value 5073746.


Message Edited by JeffOverton on 03-19-2008 09:41 AM
0 Kudos
Message 4 of 5
(3,274 Views)
Hi Karthikey,

example in more detail:

before typecast:
U16 = 16706 -> bitpattern [0100 0001 0100 0010]

after typecast:
array of U8 = [65, 66] -> bitpattern [0100 0001, 0100 0010]
or
string = "AB" -> bitpattern [0100 0001, 0100 0010]


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 5
(3,264 Views)