• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting binary to decimal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Converting binary to decimal (From: Bernardo Hoehl <email@hidden>)

  • Prev by Date: Re: Applescript-users Digest, Vol 2, Issue 4
  • Next by Date: New Year's gift for Netscape users
  • Previous by thread: Re: Converting binary to decimal
  • Next by thread: Re: Converting binary to decimal
  • Index(es):
    • Date
    • Thread