12 ms·
The article explicitly says "For the sake of simplicity, in this series of posts, we assume that the argument is positive and we allow the function to round an
by niggler 13y ago
The article explicitly says
"For the sake of simplicity, in this series of posts, we assume that the argument is positive and we allow the function to round any which way if the float argument is exactly in-between two integers."
As a result, adding the condition
float myround(float f)
{
if(f < 0) return -myround(-f); /* <-- the fix */
/* ... */
}
suffices
- jstanley 13y agoMy mistake, I didn't notice that.