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

  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: (long) x and (long) floor(x)
  5. Date: 14 Dec 1992 12:05:43 GMT
  6. Organization: Tampere University of Technology
  7. Lines: 18
  8. Distribution: world
  9. Message-ID: <1ghtanINNcf9@cs.tut.fi>
  10. NNTP-Posting-Host: vuoripyy.cs.tut.fi
  11.  
  12.  
  13. I just spent several hours debugging a simple program and before
  14. crying Compiler Bug I would like to make sure that there is one.
  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. Does the standard guarantee this or is there a loop hole that has to
  23. do with finite precision arithmetic and which allows the compiler to
  24. do what it chooses?
  25.  
  26. Petri Haavisto
  27.  
  28. PS. For those who might be interested, the compiler that caused the
  29. problems was Microsoft C (version 6.something) for MSDOS.
  30.