home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume5 / xldimage / part02 / value.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-13  |  715 b   |  39 lines

  1. /* value.c:
  2.  *
  3.  * routines for converting byte values to long values.  these are pretty
  4.  * portable although they are not necessarily the fastest things in the
  5.  * world.
  6.  *
  7.  * jim frost 10.02.89
  8.  *
  9.  * Copyright 1989 Jim Frost.  See included file "copyright.h" for complete
  10.  * copyright information.
  11.  */
  12.  
  13. #include "copyright.h"
  14. #include "image.h"
  15.  
  16. unsigned long memToVal(p, len)
  17.      byte *p;
  18.      int   len;
  19. { unsigned int  a;
  20.   unsigned long i;
  21.  
  22.   i= 0;
  23.   for (a= 0; a < len; a++)
  24.     i= (i << 8) + *(p++);
  25.   return(i);
  26. }
  27.  
  28. void valToMem(val, p, len)
  29.      unsigned long  val;
  30.      byte          *p;
  31.      unsigned int   len;
  32. { int a;
  33.  
  34.   for (a= len - 1; a >= 0; a--) {
  35.     *(p + a)= val & 0xff;
  36.     val >>= 8;
  37.   }
  38. }
  39.