Message-ID: <37506CEA.7FA8@ns.sympatico.ca> From: Klaas Organization: N/A X-Mailer: Mozilla 3.04 (Win95; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: how to round fp-numbers correctly ? References: <8710ed13 DOT 2481af58 AT aol DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 9 Date: Sat, 29 May 1999 19:40:42 -0300 NNTP-Posting-Host: 142.177.33.123 X-Trace: sapphire.mtt.net 928017963 142.177.33.123 (Sat, 29 May 1999 19:46:03 ADT) NNTP-Posting-Date: Sat, 29 May 1999 19:46:03 ADT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > where min is the lower bound integer number. If you don't have > bounded numbers, then what you said is right, you need to treat > positive and negative numbers separately. For example, a macro > #define ROUND(x) ((x >= 0) ? (int) (x + 0.5) : (int) (x - 0.5)) > should do the trick. > How about: #define ROUND(x) ((x) + SGN(x)*0.5)