[BL] dc

Lee Forrest lforrestster at gmail.com
Wed Feb 7 10:57:48 EST 2007


On Thu, Feb 08, 2007 at 08:58:10AM +1300, 3aoo-cvfd at dea.spamcon.org wrote:
> Following on from our recent discussion of dc
> (the CLI calculator in BL3), I have discovered
> something new about it.  It can do base 16 math.
> 
> base 10 math
> ------------
> dc 8 4 + p        = 12
> ------------
> 
> base 16 math
> ---------------
> dc 16 o 8 4 + p   = c
> ---------------

Hexadecimal! That's pretty neat. I'll put that in my man page.
The syntax required by dc is pretty different, so I worked out some
examples and put those in my man page:

dc 4 8 + 4 4 + + p
20
dc 4 8 4 4 + + + p
20
dc 4 8 + 2 / p
6
dc 2 2 + 2 2 + 2 2 + + + p
12
dc 2 2 2 2 + + + p
8
dc 2 2 2 + + p
6
dc 2 2 2 + + 3 / p
2
dc 8 8 \* 2 2 + / p
16

If it wasn't for the examples given by 'dc -help' I'd have been
totally stray.

No sign of base 2 yet (?).

Lee

-- 
BasicLinux: Small is Beautiful
http://www.basiclinux.com.ru




More information about the BasLinux mailing list