Article View: comp.std.c
Article #3036Re: (long) x and (long) floor(x)
From: Haavisto Petri
Date: Thu, 17 Dec 1992 11:26
Date: Thu, 17 Dec 1992 11:26
21 lines
1275 bytes
1275 bytes
In article <1992Dec16.213428.2832@delfin.com> gordon@delfin.com writes: >In article <1ghtanINNcf9@cs.tut.fi> pjh@cs.tut.fi (Haavisto Petri) writes: > >>I don't have the standard, but it seems clear to me that given an >>expression of type double with a positive value, the following >>should always be true: >> >> (long) (expression) == (long) floor(expression) > >I also don't have the standard, but I have observed that the above will >fail for cases where the expression is negative. Yes. The corresponding condition for negative expressions is (long) (expression) == (long) ceil(expression) Several people have pointed out that my example "fails" with negative expressions. I understand this very well and that is why I specifically said the expression has a positive value. Petri Haavisto
Technical Details
Message-ID:
<1gpo4uINN2g3@cs.tut.fi>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!news.cs.tut.fi!pjhReferences:
<1ghtanINNcf9@cs.tut.fi> <1gk0krINNg59@cs.tut.fi> <1992Dec16.213428.2832@delfin.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!news.cs.tut.fi!pjh From: pjh@cs.tut.fi (Haavisto Petri) Newsgroups: comp.std.c Subject: Re: (long) x and (long) floor(x) Date: 17 Dec 1992 11:26:22 GMT Organization: Tampere University of Technology Lines: 21 Distribution: world Message-ID: <1gpo4uINN2g3@cs.tut.fi> References: <1ghtanINNcf9@cs.tut.fi> <1gk0krINNg59@cs.tut.fi> <1992Dec16.213428.2832@delfin.com> NNTP-Posting-Host: vuoripyy.cs.tut.fi