[LinuxBIOS] Convert hex to dec

Uwe Hermann uwe at hermann-uwe.de
Thu Jul 5 09:18:26 CEST 2007


On Thu, Jul 05, 2007 at 05:58:18AM +0200, Stefan Reinauer wrote:
> * Uwe Hermann <uwe at hermann-uwe.de> [070704 19:47]:
> > I use some aliases in my .bashrc which are pretty handy for converting
> > HEX or BINARY or DECIMAL:
> > 
> > alias HEX="ruby -e 'printf(\"0x%X\n\", ARGV[0])'"
> > alias DEC="ruby -e 'printf(\"%d\n\", ARGV[0])'"
> > alias BIN="ruby -e 'printf(\"%bb\n\", ARGV[0])'"
> > 
> > Usage:
> > 
> > $ HEX 78
> > 0x4E
> > $ BIN 0x6a
> > 1101010b
> > $ DEC 0x72
> > 114
> 
> cool stuff. Can it easily be fixed to convert  binary into hex or dec,
> too?

Yes, that works already (the syntax is a bit strange, though):

$ HEX 0b10101010
0xAA
$ DEC 0b10000011
131


Uwe.
-- 
http://www.hermann-uwe.de  | http://www.holsham-traders.de
http://www.crazy-hacks.org | http://www.unmaintained-free-software.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20070705/1a8f34db/attachment.sig>


More information about the coreboot mailing list