floor/ceil man pages

Joseph Myers josmyers@redhat.com
Thu Jan 29 16:27:04 GMT 2026


On Thu, 29 Jan 2026, Alejandro Colomar wrote:

> > "ceil(-0.5) is 0.0".  I can't find a reference, but (1) this looks
> > weird, and (2) it looks like libc actually returns -0.0 which makes
> > more sense.  As noted above, ceil(-0.0) is required to be -0.0 if if
> > ceil(-0.5) were to return +0.0 it would make ceil a non-monotonic
> > function.
> 
> I have no idea.  It doesn't seem to be specified by the standard.
> Joseph, do you know if the floating-point group has talked anything
> about this recently?

round, floor, ceil, trunc and roundeven (of non-NaN) always return a 
result with the sign of their input, including when that result is zero.  
This is not anything new.

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-help mailing list