7th February
2008
BC is a great math library. Its extremely flexible and can be easily used in scripts.
It can also be useful for command line conversions.
Say you want the HEX equivalent of 255
bc
obase=16
255
FF
You enter bc, change your base to 16 for HEX type in 255 and it spits out FF the HEX value of 255.
Now if you want the the binary value of 255 you only need to do the following.
obase=2
255
11111111
As you can see it converted 255 into 11111111.
You can use it for other things with pipes as well.
echo 5*5-3 | bc
And if you want to use floating point numbers try bc -l
Identica
Twitter
LinkedIn