Sponsored Links

Maxabout.com > Tips

Bash - Working With Binary, Hex And Base 3.

Added on:8/27/2008 10:00:12 PM
In Linux Tips
 Rated by 1 users


  1. For the variable must be declare as an integer. Then specify the  <base>#<value>. The example below is 22 in base 3.
    $ declare -i n $ n=3#22 $ echo $n
    8

  2. Base 16 (hex)
    $ declare -i n2 $ n2=16#a $ echo $n2
    10

  3. Base 8 (octal)
    $ declare -i n3 $ n3=8#11 $ echo $n3
    9 Note 8+1=9


Sponsored Links
Tools
Bookmark/Discuss