Re: 2^1024
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