Posted to tcl by patthoyts at Tue Jan 05 19:04:19 GMT 2010view raw
- #include <float.h>
- double
- round(double x)
- {
- double t;
- if (!_finite(x))
- return (x);
- if (x >= 0.0) {
- t = floor(x);
- if (t - x <= -0.5)
- t += 1.0;
- return (t);
- } else {
- t = floor(-x);
- if (t + x <= -0.5)
- t += 1.0;
- return (-t);
- }
- }