| www.delorie.com/archives/browse.cgi | search |
| From: | shaman AT nlc DOT net DOT au |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Problems with DJGPP V2.01 - atof() function |
| Date: | Thu, 05 Dec 1996 07:56:10 +1100 |
| Organization: | NHJ NORTHLINK COMMUNICATIONS |
| Lines: | 17 |
| Distribution: | inet |
| Message-ID: | <32A5E56A.1BE3@nlc.net.au> |
| References: | <329e68a5 DOT 10316617 AT news DOT ua DOT pt> <32A03F1D DOT 4967 AT pobox DOT oleane DOT com> <32a3151a DOT 978532 AT news DOT ox DOT ac DOT uk> |
| Reply-To: | shaman AT nlc DOT net DOT au |
| NNTP-Posting-Host: | dialine21.nlc.net.au |
| Mime-Version: | 1.0 |
| To: | George Foot <mert0407 AT sable DOT ox DOT ac DOT uk> |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
>
> #define _round(x) ((int)(floor((x)+0.5)))
>
That doesn't work for negative numbers. Macros are evil anyway, so just
use this inline function:
inline int round( float in ){ return (int)( in>0 ? in+0.5 : in-0.5 ); }
--
. . . the Lord Shaman
------------------------------------------------------------------
Pentiums melt in your PC, not in your hand.
http://www.nlc.net.au/~shaman or mailto:shaman AT nlc DOT net DOT au
------------------------------------------------------------------
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |