Re: Converting binary to decimal
Re: Converting binary to decimal
- Subject: Re: Converting binary to decimal
- From: Joshua See <email@hidden>
- Date: Tue, 4 Jan 2005 09:03:02 -0600
On Jan 3, 2005, at 9:59 PM, Bernardo Hoehl wrote:
Has anyone ever written a handler to convert binary to decimal?
Shorter than Michelle's and clearer than Gnarlodious's, it should still
fail on any invalid input:
set {binstr, pow, out} to {"1111111", 0, 0}
set binstr to reverse of characters of binstr
repeat with i in binstr
if (i as integer) > 1 then
error "Bad input!"
end if
set out to out + ((i as integer) * (2 ^ pow))
set pow to pow + 1
end repeat
out
--
Sincerely,
Joshua See
_______________________________________________
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