• 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: 2^1024
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 2^1024


  • Subject: Re: 2^1024
  • From: "Arthur J. Knapp" <email@hidden>
  • Date: Mon, 26 Feb 2001 16:33:59 -0500

> Date: Mon, 26 Feb 2001 19:12:28 +0000
> Subject: Re: 2^1024
> From: Simon Forster <email@hidden>

> >From: email@hidden
> > And displaying "132" will get you shot.

> Not at all. I had just counted this out when my better half walked in. She
> just thought I was communicating with my computer in customary fashion.

No need to count it out:

set leftHand to "00100"
set rightHand to "00100"

set fingers to leftHand & rightHand
set theInteger to bits2integer(fingers)
-- > 132

on bits2integer(bitString)

set pow to 0
set num to 0

repeat with b in reverse of characters of bitString

set num to num + (b * (2 ^ pow))
set pow to pow + 1

end repeat

return num

end bits2integer


-- Victory:
bits2integer("00110" & "01100") -- > 204

-- Thumb a ride:
bits2integer("00001" & "10000") -- > 48

-- A british guy drinking tea, (with his left hand):
bits2integer("00000" & "00001") -- > 1

There may be some ambiguity regarding which side of the hand
we're talking about here. Should we get the ISO to standardize
this? ;-)



Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden

Hey, check out:
http://www.AppleScriptSourceBook.com


  • Prev by Date: Re: weird comparison problem
  • Next by Date: Moving printers
  • Previous by thread: Re: 2^1024
  • Next by thread: De-lurk and Pop-up windows question
  • Index(es):
    • Date
    • Thread