home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3224 < prev    next >
Encoding:
Internet Message Format  |  1992-12-17  |  1.2 KB

  1. Path: sparky!uunet!mcsun!news.funet.fi!news.cs.tut.fi!pjh
  2. From: pjh@cs.tut.fi (Haavisto Petri)
  3. Newsgroups: comp.std.c
  4. Subject: Re: (long) x and (long) floor(x)
  5. Date: 17 Dec 1992 11:26:22 GMT
  6. Organization: Tampere University of Technology
  7. Lines: 21
  8. Distribution: world
  9. Message-ID: <1gpo4uINN2g3@cs.tut.fi>
  10. References: <1ghtanINNcf9@cs.tut.fi> <1gk0krINNg59@cs.tut.fi> <1992Dec16.213428.2832@delfin.com>
  11. NNTP-Posting-Host: vuoripyy.cs.tut.fi
  12.  
  13. In article <1992Dec16.213428.2832@delfin.com> gordon@delfin.com writes:
  14. >In article <1ghtanINNcf9@cs.tut.fi> pjh@cs.tut.fi (Haavisto Petri) writes:
  15. >
  16. >>I don't have the standard, but it seems clear to me that given an
  17. >>expression of type double with a positive value, the following
  18. >>should always be true:
  19. >>
  20. >>        (long) (expression) == (long) floor(expression)
  21. >
  22. >I also don't have the standard, but I have observed that the above will
  23. >fail for cases where the expression is negative.
  24.  
  25. Yes. The corresponding condition for negative expressions is
  26.  
  27.         (long) (expression) == (long) ceil(expression)
  28.  
  29. Several people have pointed out that my example "fails" with negative
  30. expressions. I understand this very well and that is why I specifically
  31. said the expression has a positive value.
  32.  
  33. Petri Haavisto
  34.