On Fri, 2023-11-24 at 16:01 +0800, chenglulu wrote: > I only saw lrint llrint in n2310 with this description: > > F7.12.9.5 > > "The lrint and llrint functions round their argument to the nearest > integer value, rounding > according to the current rounding direction. If the rounded value is > outside the range of the return > type, the numeric result is unspecified and a domain error or range > error may occur." > > I don't know if I'm right?
There's an explanation in the linux man-page for lrint: SUSv2 and POSIX.1‐2001 contain text about overflow (which might set er‐ rno to ERANGE, or raise an FE_OVERFLOW exception). In practice, the result cannot overflow on any current machine, so this error‐handling stuff is just nonsense. (More precisely, overflow can happen only when the maximum value of the exponent is smaller than the number of man‐ tissa bits. For the IEEE‐754 standard 32‐bit and 64‐bit floating‐point numbers the maximum value of the exponent is 127 (respectively, 1023), and the number of mantissa bits including the implicit bit is 24 (re‐ spectively, 53).) -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University