home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d8xx
/
d811
/
bsh.lha
/
bsh
/
binary
< prev
next >
Wrap
Text File
|
1993-02-14
|
760b
|
28 lines
if !?argv[1]
label usage
echo usage: binary number
exit 10
endif
if !numeric(argv[1])
goto usage
endif
local number result
if number=argv[1]
result=""
else
result="0"
endif
while number
result=cat(number&1,"$result"),number=(number>>1)&0x7fffffff
endwhile
echo $result
exit 0
# Binary - convert a decimal number to binary. Normally, strings which
# contain only digits are considered to be numeric and are therefore
# subject to loss of leading zeros; this is why result is quoted in
# the loop.
# Binary is presented as is; no warrantee is either expressed or implied
# as to it's suitability to any purpose whatsoever. You assume all the
# risk for all damage, even if caused by a defect in the software, no
# matter how awful.