Tuesday, November 6, 2007

converting binary and decimal numbers with maple

from decimal to binary:
convert(12345, binary);

from binary to decimal:
convert(11000000111001, decimal, binary);

2 comments:

admin said...

Or, if you're at a command line and/or don't have maple installed:

decimal to binary:

echo "2 o 12345 p" | dc

binary to decimal:

echo "2 i 11000000111001 p" | dc

Also usable for hexadecimal etc.:

echo "16 o 123456 p" | dc

... or even converting from, say, base-7 to base-13:

echo "7 i 13 o 123456 p" | dc

leo said...

Thanks, vocho amarillo, that's pretty useful!