standards/59797: Implement C99's round[f]() math fucntions

Stefan Farfeleder stefan at fafoe.narf.at
Sat Nov 29 15:51:52 PST 2003


The following reply was made to PR standards/59797; it has been noted by GNATS.

From: Stefan Farfeleder <stefan at fafoe.narf.at>
To: "Steven G. Kargl" <kargl at troutmask.apl.washington.edu>
Cc: bug-followup at FreeBSD.org
Subject: Re: standards/59797: Implement C99's round[f]() math fucntions
Date: Sun, 30 Nov 2003 00:40:04 +0100

 On Sat, Nov 29, 2003 at 10:06:27AM -0800, Steven G. Kargl wrote:
 
 > >Synopsis:       Implement C99's round[f]() math fucntions
 
 Nice!
 
 > +double round(double x) {
 > +	double t;
 > +	if (x >= 0.0) {
 > +		t = ceil(x);
 > +		if (t - x > 0.5) t -= 1.0;
 > +		return t;
 > +	} else {
 > +		t = ceil(-x);
 > +		if (t + x > 0.5) t -= 1.0;
 > +		return -t;
 > +	}
 > +}
 
 One suggestion: Could you make that
 
 +double
 +round(double x)
 +{
 
 to match style(9) and (most of) msun/src/*.c?
 
 Cheers,
 Stefan


More information about the freebsd-standards mailing list