Calocybe: Wie Runde ich mit C++?

Beitrag lesen

Moin moin!

return (fmod(x,1.0) >= 0.5) ? ceil(x) : floor(x);

Na, da denke ich doch, daß das gute alte
return(floor(x+0.5));
doch noch effizienter ist;-)

Vor allem funktioniert es auch mit negativen Zahlen, im Gegensatz zur oberen Variante. ;-)

So long

--
There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.
    -- Jeremy S. Anderson