BIN2DEC bits 0-5 then 6-15

J

Jim

THX for the interest
Equipment I work on outputs error messages in HEX which I then convert to
Binary to obtain a Bit map which is then broken down into groups of Bits each
group having a meaning for example:-
Bits 0-5 = Resource number
Bits 6-7 = Resource type

I am trying to write a formula that will take the Hex value I enter convert
it to a bit map and output the data in Dec with the value of Bit groups in
different cells.
 
G

Gary''s Student

An interesting problem.


In B1 enter a valid 4-character hex value:

0000
thru
FFFF

In C1 enter:
=HEX2BIN(LEFT(B1,1),4) & HEX2BIN(MID(B1,2,1),4) & HEX2BIN(MID(B1,3,1),4) &
HEX2BIN(MID(B1,4,1),4)

In D1 enter:
=BIN2DEC(LEFT(C1,6))

In E1 enter:
=BIN2DEC(RIGHT(C1,9))+512*MID(C1,7,1)


I have assumed that bit #0 is the MSB. E & D are your decimal parts. Some
typical values in B thru E are:

0008 0000000000001000 0 8
0E46 0000111001000110 3 582
DEAD 1101111010101101 55 685



--
Gary's Student


Jim said:
THX for the interest
Equipment I work on outputs error messages in HEX which I then convert to
Binary to obtain a Bit map which is then broken down into groups of Bits each
group having a meaning for example:-
Bits 0-5 = Resource number
Bits 6-7 = Resource type

I am trying to write a formula that will take the Hex value I enter convert
it to a bit map and output the data in Dec with the value of Bit groups in
different cells.
 
J

Jim

Intersting solution But too complex for me I tried to get it to work let me
try and clarify the problem.

Fault Additional Info Given in Hex
Example H'ABCD AB CD
Binary Value to obtain Bit Map 10101011 11001101

Bit 15 Bit 14 Bits 8-13 Bits 5-7 Bits 0-4
Which would decode Thus 1 0 101011 110 01101
43 6 13
Reverse Dir Busy Bit LCN DLT Time Slot

Bits 14 and 15 if 1 Then True else False

Regards



Gary''s Student said:
An interesting problem.


In B1 enter a valid 4-character hex value:

0000
thru
FFFF

In C1 enter:
=HEX2BIN(LEFT(B1,1),4) & HEX2BIN(MID(B1,2,1),4) & HEX2BIN(MID(B1,3,1),4) &
HEX2BIN(MID(B1,4,1),4)

In D1 enter:
=BIN2DEC(LEFT(C1,6))

In E1 enter:
=BIN2DEC(RIGHT(C1,9))+512*MID(C1,7,1)


I have assumed that bit #0 is the MSB. E & D are your decimal parts. Some
typical values in B thru E are:

0008 0000000000001000 0 8
0E46 0000111001000110 3 582
DEAD 1101111010101101 55 685
 
G

Gary''s Student

Hi Jim:

Thanks for the clarification. I'll update tomorrow, splitting the 16 bits
into 5 groups:

bit 15
bit 14
bits 13-8
bits 7-5
bits 4-0
--
Gary''s Student


Jim said:
Intersting solution But too complex for me I tried to get it to work let me
try and clarify the problem.

Fault Additional Info Given in Hex
Example H'ABCD AB CD
Binary Value to obtain Bit Map 10101011 11001101

Bit 15 Bit 14 Bits 8-13 Bits 5-7 Bits 0-4
Which would decode Thus 1 0 101011 110 01101
43 6 13
Reverse Dir Busy Bit LCN DLT Time Slot

Bits 14 and 15 if 1 Then True else False

Regards
 
Top