This is old and not really optimized, but may be what you want...
on getBinary vNum, vDepth
if vDepth = void then vDepth = 32
baseNums = ["0","1"]
n = ""
neg = 0
if vnum < 0 then
neg = 1
vnum = integer(the maxInteger + 1.0 + vNum)
end if
vNum = integer(vNum)
repeat while vNum
nMod = vNum mod 2
put string(baseNums[nMod + 1]) before n
vNum = vNum / 2
end repeat
--add preceeding 0
repeat while n.char.count < vDepth - 1
put "0" before n
end repeat
if n.char.count < vDepth then
put neg before n
end if
return n
end
on getInt vBinary
baseNums = ["0","1"]
if vBinary.char[1] = "1" then negative = 1
nConverted = 0
nMax = vBinary.length
repeat with nIndex = 1 to nMax
nConverted = nConverted * 2
nConverted = nConverted + baseNums.getOne(vBinary.char[nIndex]) - 1
end repeat
return nConverted
end
-Chuck
--------------------------
Chuck Neal
CEO, MediaMacros, Inc.
[EMAIL PROTECTED]
http://www.mediamacros.com
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of 2702NET
Sent: Wednesday, April 28, 2004 6:24 AM
To: [EMAIL PROTECTED]
Subject: <lingo-l> decimal to binary conversion...
Hi all,
Anyone have code for decimal to binary conversion you wouldn't mind
posting?
TIA,
J
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is
for learning and helping with programming Lingo. Thanks!]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL
PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping
with programming Lingo. Thanks!]