Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Hex to Binary conversion (helping function provided from another post)

I am receiving data for the operation of some sensors which is in Hex format. 

In order to see which sensor is on and which is off, I need to convert this into Binary, thus know which sensors are on or off.

 

example: I get 

0xc00000200
0x1000000
0x400000
0x500000000

0x400040000

0x0

 

Each row of the Hex after 0x at full length must be of 12 characters, so:

0x0 = 0x000000000000 

0x400040000 = 0x000400040000

etc...

the binary results should be of length something like:

0000 0000 0000 1010 0000 0000 0000 0000 0001 0000 0000 0000

 

where each character of the binary represents a sensor.

 

Question: When the HEX  is converted to Binary like above. How am i going to define the name of each of the character in the binary? 

 

so if 0000 0000 0000 1010 ......  I would be able to reverse it and give each of the binary character a name like B1, B2, B3 ... B48.

 

I was hoping someone with good coding knowledge could make this Hex to Decimal function to Hex to Binary instead, in addition of the above requirements. 

 

 

Hope someone has a good solution to this, thanks Smiley Happy

Greg_Deckler