Re: Converting binary to decimal
Re: Converting binary to decimal
- Subject: Re: Converting binary to decimal
- From: Martin Orpen <email@hidden>
- Date: Tue, 04 Jan 2005 10:07:49 +0000
on 4/1/05 4:53 am, Gnarlodious wrote:
> set binString to "11111111"
> do shell script "echo \"2 10 o i " & binString & " p\" | dc"
Nice - finally a reason to use dc instead of bc.
And for Jon, the trick here is that dc lets you set different values for the
input and output radices.
So Gnarlie is using 2 and 10 to input binary and output decimal.
This is a cool technique because you can adapt it to handle other base
conversions:
"2 8 o i" for binary to octal
"10 2 o i" for decimal to binary
The man page states: "The input radix must be between 2 and 16 inclusive.
The output radix must be at least 2."
Which makes me think that you could also use it for PITA time conversions
using "10 60" - must experiment with that later...
Cheers Gnarlie.
--
Martin Orpen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden