I need to do rounding on a number, but I don't know whether that number is negative or positive.
Is there a better way to round foo
that to do this:
static_cast<int>(foo > 0 ? foo + 0.5 : foo - 0.5)
Basically I want this behavior:
3.4 => 3
3.5 => 4
-3.4 => -3
-3.5 => -4