🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3019

(long) x and (long) floor(x)

#3019
From: Haavisto Petri
Date: Mon, 14 Dec 1992 12:05
18 lines
1006 bytes
I just spent several hours debugging a simple program and before
crying Compiler Bug I would like to make sure that there is one.

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)

Does the standard guarantee this or is there a loop hole that has to
do with finite precision arithmetic and which allows the compiler to
do what it chooses?

Petri Haavisto

PS. For those who might be interested, the compiler that caused the
problems was Microsoft C (version 6.something) for MSDOS.
Technical Details
Message-ID: <1ghtanINNcf9@cs.tut.fi>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!news.cs.tut.fi!pjh

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: (long) x and (long) floor(x)
Date: 14 Dec 1992 12:05:43 GMT
Organization: Tampere University of Technology
Lines: 18
Distribution: world
Message-ID: <1ghtanINNcf9@cs.tut.fi>
NNTP-Posting-Host: vuoripyy.cs.tut.fi