floor/ceil man pages

Alejandro Colomar alx@kernel.org
Thu Jan 29 15:37:36 GMT 2026


[TO += Joseph]
[CC += libc-help@]

Hi Morten, Joseph,

On 2026-01-28T09:51:47-0500, Morten Welinder wrote:
> I see two minor problems:
> 
> "If x is integral, +0, -0, NaN, or infinite, x itself is returned." --
> this seems to suggest that NaN is passed through unchanged, i.e., the
> type and sign of the NaN is unchanged.  Other references I can find
> suggest that the NaN details are not guaranted.  See
> https://en.cppreference.com/w/c/numeric/math/floor.html, for example.

Would you mind quoting the specific text that you think suggests that?
I see in that page

	If arg is NaN, NaN is returned.

> "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?


Have a lovely day!
Alex

> 
> M.
> 

-- 
<https://www.alejandro-colomar.es>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-help/attachments/20260129/266544bd/attachment.sig>


More information about the Libc-help mailing list