home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / UNSIGNED.ICN < prev    next >
Text File  |  1991-07-13  |  1KB  |  40 lines

  1. ############################################################################
  2. #
  3. #    Name:    unsigned.icn
  4. #
  5. #    Title:    Puts bits of characters of a string into an integer
  6. #
  7. #    Author:    Robert J. Alexander
  8. #
  9. #    Date:    April 2, 1990
  10. #
  11. ############################################################################
  12. #
  13. #  unsigned() -- Puts raw bits of characters of string s into an
  14. #  integer.  The value is taken as unsigned.
  15. #
  16. #  If large integers are supported, this routine will work for integers
  17. #  of arbitrary size.
  18. #
  19. #  If large integers are not supported, the following are true:
  20. #
  21. #    If the size of s is the same as or greater than the size of an
  22. #    integer in the Icon implementation, the result will be negative or
  23. #    positive depending on the value of the integer's sign bit.
  24. #
  25. #    If the size of s is less than the size of an integer, the bytes are
  26. #    put into the low order part of the integer, with the remaining high
  27. #    order bytes filled with zero.  If the string is too large, the most
  28. #    significant bytes will be lost.
  29. #
  30. #  This procedure is normally used for processing of binary data read
  31. #  from a file.
  32. #
  33.  
  34. procedure unsigned(s)
  35.    local i
  36.    i := 0
  37.    every i := ior(ord(!s),ishift(i,8))
  38.    return i
  39. end
  40.