Date: Fri, 28 Nov 2003 16:01:33 -0800 From: Steve Kargl <sgk@troutmask.apl.washington.edu> To: freebsd-standards@freebsd.org Subject: Implementing C99's roundf(), round(), and roundl() Message-ID: <20031129000133.GA30662@troutmask.apl.washington.edu>
index | next in thread | raw e-mail
Can the math functions round[fl]() be implemented in
terms of other math(3) functions and still conform to the
C99 and POSIX standard? For example,
#include <math.h>
float roundf(float x) {
float t;
if (x >= 0.0) {
t = ceilf(x);
if ((t - x) > 0.5) t -= 1.0;
return t;
} else {
t = ceilf(-x);
if ((t + x) > 0.5) t -= 1.0;
return -t;
}
}
--
Steve
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031129000133.GA30662>
