
18 Jul
2004
18 Jul
'04
12:37 a.m.
I was reading the Boost documentation, and couldn't find a function to round floating point numbers (up or down) to the nearest integer. I have my own implementation of this algorithm as follows: #include <math.h> double round(double number) { return number < 0.0 ? ceil(number-0.5) : floor(number+0.5); } This round function produces the following output: round(0.0) = 0 round(1.49) = 1 round(1.5) = 2 round(-1.49) = -1 round(-1.5) = -2 Does Boost contain a simple rounding function like this? Thanks in advance, ~Matt Verona matt_verona@acm.org Houston, Texas USA