[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: converting numbers



> Where's the FM that tells how to convert numbers, like 0x11A to a 
> "decimal"?

I use 'dc' for this sort of task, for example:

plum:~$ dc	Invoke the program
16		push 16 on the stack
i		pop 16 from the stack and set it as the input radix
11A		push 0x11A on the stack
p		print the top number on the stack
282		by default, output radix is 10


One can go on and display the number in other radices (sp?):

8		push 8
o		set output radix
p		print
432		here it is in octal
2		push 2
o		set output radix
p		print
100011010	and now in binary
q		all done
plum:~$

'dc' has a good man page - and it's fun too!

Michael


Reply to: