From: Mbaccar AT aol DOT com Message-ID: <40af648d.2481dc42@aol.com> Date: Sat, 29 May 1999 20:11:46 EDT Subject: Re: how to round fp-numbers correctly ? To: djgpp AT delorie DOT com CC: Mbaccar AT aol DOT com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: AOL 4.0 for Windows sub 11 Reply-To: djgpp AT delorie DOT com In a message dated 5/29/99 7:03:52 PM EST, klaas AT ns DOT sympatico DOT ca writes: > How about: > #define ROUND(x) ((x) + SGN(x)*0.5) Looks good to me. Probably what you could do also is sgn(x) * ((int) fabs(x) + 0.5) The reason is simple. There is a discontinuity about 0. 0.6 -> 1 0.6-1 = -0.4 -> -1 using your rule (or my previous which is the same) so now the delta between the integer numbers of 0.6 and -0.4 is 2 which seems incorrect considering the true delta is 1.0. This is what you need to watch for in any case.