**Submitter:** Fred Tydeman (US)

**Submission Date:** 2001-02-25

**Source:**

**Reference Document:** ISO/IEC
WG14 N943

**Version:** 1.1

**Date:** 2001-10-16 09:50:00

**Subject:** ` lrint`,

**Summary**

,lrint,llrint,lround, andllroundneed to have consistent and explicit descriptions when results are too big to represent in an integer type. Also, that case should be treated as a domain error.ilogb

**Details**

IEC 60559 requires that when a large floating-point value, an infinity, or a NaN is converted to an integer, and the result cannot be represented as an integer in the result's format, an invalid operation has occurred. This is currently mostly reflected in C99's Annex F. This condition corresponds to C's domain error.

does not discuss (in either 7.12.6.5 or annex F) what should happen if the expected result cannot be represented as anilogbint. It should be treated as a domain error (because it is an invalid operation to IEC 60559). The "correct" result ofis -infinity (which cannot be represented as anilogb(0)int, so should be treated as a domain error).does not follow the normal convention of NaN in implies NaN out, so this unusual case needs to be discussed.ilogb(NaN)

andlrintare inconsistent on how large arguments are treated between 7.12.9.5 (range error) and Annex F (domain error).llrint

andlroundare inconsistent on how large arguments are treated between 7.12.9.7 (range error) and Annex F (domain error).llround

**Suggested Technical Corrigendum**

In 7.12.6.5 ` ilogb`:

Change:

A range error may occur iftoisx.0

A domain error occurs ifAdd:isx, infinite, or0.NaN

If the correct value is outside the range of the return type, the numeric result is unspecified, and a domain error occurs.In 7.12.9.5

Change:

If the rounded value is outside the range of the return type, the numeric result is unspecified. A range error may occur if the magnitude oftois too large.x

If the rounded value is outside the range of the return type, the numeric result is unspecified, and a domain error occurs.In 7.12.9.7

Change:

If the rounded value is outside the range of the return type, the numeric result is unspecified. A range error may occur if the magnitude oftois too large.x

If the rounded value is outside the range of the return type, the numeric result is unspecified, and a domain error occurs.

**Proposed Technical Corrigendum**

In 7.12.6.5 ` ilogb`:

Change:

A range error may occur iftoisx.0

A domain error or range error may occur ifAdd:isx, infinite, or0.NaN

If the correct value is outside the range of the return type, the numeric result is unspecified.In F.9.3.5

Change:

No additional requirements.to

If the correct result is outside the range of the return type, the numeric result is unspecified and the "invalid" floating-point exception is raised.In 7.12.9.5

Change:

If the rounded value is outside the range of the return type, the numeric result is unspecified. A range error may occur if the magnitude oftois too large.x

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.In 7.12.9.7

Change:

is too large.x

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.