home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1220 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: phoenix.rhein.de!yaps!arno
  2. From: arno@yaps.rhein.de (Arno Eigenwillig)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Is this a SAS/C bug or have I coded it wrong?
  5. Message-ID: <+bWXx*6df@yaps.rhein.de>
  6. Date: Tue, 16 Jan 1996 17:35:58 +0100
  7. References: <4cfrc5$gsc@misery.millcomm.com> <1996Jan15.214611@clstac>
  8. Organization: Yet Another Private Site in Meckenheim, Germany
  9. X-Copyright: This article may not be distributed on a CD-ROM
  10.  or in printed form without prior written consent of the author.
  11. X-Newsreader: Arn V 1.04
  12.  
  13. In article <1996Jan15.214611@clstac>, cdubose@csupomona.edu writes:
  14.  
  15. >   if ( (tmpbuf[0] & 0x1f) == 1 )
  16.  
  17. > That expression is equivalent to (tmpbuf[0] % 32 == 1).
  18.  
  19. Only if tmpbuf[0] >= 0.
  20.  
  21. ANSI requires that a == (a/b)*b + a%b. a%b > 0 is only required in
  22. case both a and b are non-negative. For the other cases (provided a%b
  23. != 0), it is up to the compiler vendor to define whether a/b shall
  24. round towards -inf and a%b shall be positive, or a/b shall round
  25. towards 0 and a%b shall be negative.
  26.  
  27. ANDing with 2^n - 1 to compute MOD 2^n is common, but problematic if
  28. the left operand is signed, because this method always delivers
  29. positive results, whereas the m68k DIVS and hence % in straight-for-
  30. ward implementations delivers negative remainders for a < 0 < b.
  31.  
  32. -- __
  33. __/// Arno Eigenwillig /\ <arno@yaps.rhein.de> \/ PGP key available.
  34. \XX/   V+49-2225-5870  /\ <Arnooo @ #amigager> \/ MIME 8bit welcome.
  35.