OT-ish - converting hex output to binary on a Unix platform

From: Dwight K. Elvey <dwight.elvey_at_amd.com>
Date: Fri Jul 30 20:26:12 2004

>From: "Stephane Tsacas" <stephane.tsacas_at_gmail.com>
>
>I guess you have hex digit as input, not prefixed by 0x (if they are,
>remove the string "0x" from the x= statement. Maybe that code might
>help :
>
>awk --non-decimal-data 'BEGIN {RS=" ";} {x="0x"$0; s=""; while (x > 0)
> { s=and(x,1)""s; x=rshift(x,1); } print s}'
>
>0 1 2 3 4 5 6 7 8 9 a b c d e f as input will print :
>0
>1
>10
>11
>100
>101
>110
>111
>1000
>1001
>1010
>1011
>1100
>1101
>1110
>1111
>
>you can put your own code after the x= statement I guess.
>Stephane
>
---snip---

Hi
 I'm not sure this is what he is looking for. I think
he wants the hex number converted to a byte value
not just printed in ascii as a binary value.
Dwight
Received on Fri Jul 30 2004 - 20:26:12 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:36:53 BST