home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / RAYCAST.ZIP / UTILS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-10  |  423 b   |  37 lines

  1. #include "utils.h"
  2. #define ABS(X) (X<0?-X:X)
  3.  
  4. LONG strtoint(const CHAR * q)
  5. {
  6. LONG res=0;
  7. LONG i=0;
  8. LONG j;
  9. while (q[i]!='\0')
  10.   i++;
  11. if (i==0)
  12.   return 0;
  13. j=1;
  14. LONG t;
  15. while (i>0)
  16. {
  17. i--;
  18. t=q[i]-'0';
  19. if ((t>=0)&&(t<=9)) {
  20. res+=j*t;
  21. j*=10;
  22. }
  23. }
  24. return res;
  25. }
  26.  
  27. USHORT Check2Shift(ULONG number)
  28. {
  29. USHORT count=0;
  30. ULONG temp=number;
  31. while (temp>1) {
  32.   count++;
  33.   temp>>=1;
  34. }
  35. return count;
  36. }
  37.