home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d811 / bsh.lha / bsh / binary < prev    next >
Text File  |  1993-02-14  |  760b  |  28 lines

  1. if !?argv[1]
  2.     label usage
  3.     echo usage: binary number
  4.     exit 10
  5. endif
  6. if !numeric(argv[1])
  7.     goto usage
  8. endif
  9. local number result
  10. if number=argv[1]
  11.     result=""
  12. else
  13.     result="0"
  14. endif
  15. while number
  16.     result=cat(number&1,"$result"),number=(number>>1)&0x7fffffff
  17. endwhile
  18. echo $result
  19. exit 0
  20. # Binary - convert a decimal number to binary.  Normally, strings which
  21. # contain only digits are considered to be numeric and are therefore
  22. # subject to loss of leading zeros; this is why result is quoted in
  23. # the loop.
  24. # Binary is presented as is; no warrantee is either expressed or implied
  25. # as to it's suitability to any purpose whatsoever.  You assume all the
  26. # risk for all damage, even if caused by a defect in the software, no
  27. # matter how awful.
  28.