ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert hex number to binary number array

Solved!
Go to solution

Hi,

 

I need to convert hex number into binary number array.

Can someone show me how?

 

For example,

 

num1 = 0xFA

I need to put into binary array,

         index 0 1 2 3 4 5 6 7

value (LSB)0 1 0 1 1 1 1 1(MSB)

 

Thank you.

0 Kudos
Message 1 of 6
(10,050 Views)

Hi horanyee,

   Use num to boolean array function which nis present in boolean pallette....

Regards,
Srikrishna


0 Kudos
Message 2 of 6
(10,044 Views)
Additional info: if you actually want zeros and ones you can add a Boolean to 0,1 function.
0 Kudos
Message 3 of 6
(10,019 Views)

here you go ..

 

Guru

Regards
Guru (CLA)
0 Kudos
Message 4 of 6
(10,018 Views)

Guruthilak wrote:

here you go ..

 

Guru


There's a couple of issues with this solution:

  • It gives you a string array, and the OP asked for a binary number array, which I take to mean an array of zeros and ones.
  • It does not give you the full 8 bits, including the preceding zeros. This can be remedied by changing the format string to %08b.
  • A more compact way (albeit at the expense of a small coercion) to get your string array result is the following:
Message Edited by smercurio_fc on 12-21-2009 11:09 PM
0 Kudos
Message 5 of 6
(10,008 Views)
Solution
Accepted by topic author horanyee

Guru,

 

You are generating a string array instead of a number array like the op asked for and the order of your array is reversed.

 

What srikrishnaNF and smercurio_fc are descibing is this simple code.

 

Hex to Array.PNG

 

Message 6 of 6
(10,007 Views)