On Wed, Sep 19, 2012 at 09:05:58PM +0200, Marko Cebokli wrote:
> what about (unsigned char)roundf()?
Does MSVC have roundf? It's defined in exactly the same standards as rintf
(C99, POSIX).
In any case, it has most of the same problems as (int)(x + 0.5) has
(I assume you meant int or long, not unsigned char; the latter would surely
be a disaster); it needs a slow round-with-truncate, and it has a rounding
bias, so it rounds e.g. 0.5 wrong. It's somewhat better with negative
numbers, though.
/* Steinar */
--
Homepage:
http://www.sesse.net/