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

  1. ############################################################################
  2. #
  3. #    Name:    intstring (intstr.icn)
  4. #
  5. #    Title:    Creates a string consisting of the raw bits of an integer.
  6. #
  7. #    Author:    Robert J. Alexander
  8. #
  9. #    Date:    April 2, 1990
  10. #
  11. ############################################################################
  12. #
  13. #  intstring() -- Creates a string consisting of the raw bits in the low
  14. #  order "size" bytes of integer i.
  15. #
  16. #  This procedure is normally used for processing of binary data
  17. #  to be written to a file.
  18. #
  19. #  Note that if large integers are supported, this procedure still
  20. #  will not work for integers larger than the implementation defined
  21. #  word size due to the shifting in of zero-bits from the left in the
  22. #  right shift operation.
  23. #
  24.  
  25. procedure intstring(i,size)
  26.    local s
  27.    s := ""
  28.    every 1 to size do {
  29.       s := char(iand(i,16rFF)) || s
  30.       i := ishift(i,-8)
  31.       }
  32.    return s
  33. end
  34.