I have a code
private float roundAwayFrom0(float value) {
float abs = Math.abs(value);
float sign = (value == 0) ? 1 : value / (abs);
return (sign * (Math.round(abs)));
}
And when
sign = -1f
and
Math.round(abs) = 0
I have expected that result should be 0.0f
But the actual is -0.0f
. What the magic?