[cfp-interest 3951] Re: Weird Casting Error

Damian McGuckin damianm at esi.com.au
Wed Jun 10 13:53:08 PDT 2026


On Wed, 10 Jun 2026, Joshua Cranmer wrote:

> With Annex F, the resulting value is unspecified (see F.4). Without 
> Annex F, the rule is given in 6.3.14:
>
> On 6/10/2026 11:50, Vincent Lefevre wrote:
>
>>  When a finite value of standard floating type is converted to an
>>  integer type other than bool, the fractional part is discarded (i.e.,
>>  the value is truncated toward zero). If the value of the integral part
>>  cannot be represented by the integer type, the behavior is undefined.

Thanks for finding that clause Joshua. My fishing skills sometimes fail.

Sorry, Fred, Vincent and Joshua - I should have been more explicit. I was 
talking in the context of Annex F, not the main body of the C standard. I 
was wondering whether we needed a Recommended Practice paragraph or a NOTE 
or a footnote about dealing with casting to unsigned numbers in Annex F.

I was also asking the question in the context of some discussion going on 
within IEEE 754R at the moment and was looking for some discussion to help 
clarify my own thoughts.

Most modern CPUs return the indefinite integer (which is neither a C 
standard concept nor an IUEEE 754 (ISO 60559 concept) when either (as 
Vincent mentioned)

a) "... a NaN or infinite operand cannot be represented in the
    destination format and this cannot otherwise be indicated, the
    invalid operation exception shall be signaled" or
b) "... a numeric operand would convert to an integer outside the
    range of the destination format, the invalid operation exception
    shall be signaled if this situation cannot otherwise be indicated

Thanks for the feedback - Damian

P.S. Thanks David for getting the mailing list wordking again. My own
apologies to those to whom I sent some extra noise during its downtime.


More information about the cfp-interest mailing list