Re: Binary => decimal conversion
Re: Binary => decimal conversion
- Subject: Re: Binary => decimal conversion
- From: email@hidden
- Date: Mon, 27 Nov 2000 14:49:52 EST
--here is a sample. it only goes to 8-bit(0-255), but you can make it longer
by following the pattern:
set d to 1
set e to 0
set c to the text returned of (display dialog "Enter an 8 bit binary number"
default answer "00000000")
if item 1 of c is "1" then
set e to (e + 128)
end if
if item 2 of c is "1" then
set e to (e + 64)
end if
if item 3 of c is "1" then
set e to (e + 32)
end if
if item 4 of c is "1" then
set e to (e + 16)
end if
if item 5 of c is "1" then
set e to (e + 8)
end if
if item 6 of c is "1" then
set e to (e + 4)
end if
if item 7 of c is "1" then
set e to (e + 2)
end if
if item 8 of c is "1" then
set e to (e + 1)
end if
display dialog e