home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16157 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.2 KB

  1. Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!wirzeniu
  2. From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: single formula for number of bits set in a byte
  5. Message-ID: <1992Nov7.215347.21360@klaava.Helsinki.FI>
  6. Date: 7 Nov 92 21:53:47 GMT
  7. References: <530@ulogic.UUCP> <6444@ucsbcsl.ucsb.edu> <566@ulogic.UUCP>
  8. Organization: University of Helsinki
  9. Lines: 18
  10.  
  11. hartman@ulogic.UUCP (Richard M. Hartman) writes:
  12. >I have never met a compiler that yields other than 1 and 0 for
  13. >equality and relational expressions.
  14.  
  15. Even K&R-1 said that the result of a boolean expression is either 0 or
  16. 1, even though any non-zero value in a boolean context stands for
  17. "true".  IMHO, any compiler which gets this wrong is seriously broken.
  18.  
  19. >For C++ compilers this is guaranteed in the ARM (p74, section 5.9).
  20. >Unfortunately I don't have the ANSI C compiler document available
  21. >but I would suspect this is guarenteed there also.
  22.  
  23. It is.  Don't have the standard itself, but "Standard C" by Plauger and
  24. Brodie describes this behaviour for every boolean operator. 
  25.  
  26. --
  27. Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
  28.    MS-DOS, you can't live with it, you can live without it.
  29.