Re: Kind of NOT integer constant
- From: "James Giles" <jamesgiles@xxxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 20:10:54 GMT
Jan Vorbrüggen wrote:
....
>> i = 2147483647
>> j = 2147483645
>> li = i+j
>> print *, li, (i+j)/2
>>
>> Is the processor prohibited from printing
>>
>> 4294967292 2147483646
>>
>> even if the answer for the second value *is* permtted?
>
> If the answer for the second value were permitted, I would _require_,
> for consistency, the first value you show. However, I think in this
> example the second value is not permitted: the expression i+j is
> evaluated with a result the same kind as i and j, which for this being
> a 32-bit integer will lead to overflow. [...]
There is no concept of overflow in the standard document.
An implementation is not required to detect, report, or
"wrap" values on overflow. It *IS* permitted that it carry
extra precision for the intermediate calculations of an
integer expression. Otherwise, I would say, for consistency,
that the corresponding floating point example would *have*
to overflow:
dble_var = huge(0.0) + huge(0.0)
And we all know that the standard does *not* require that
to overflow.
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
.
- References:
- Re: Kind of NOT integer constant
- From: glen herrmannsfeldt
- Re: Kind of NOT integer constant
- From: Richard E Maine
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: Jan Vorbrüggen
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: Richard E Maine
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: Richard E Maine
- Re: Kind of NOT integer constant
- From: Paul Van Delst
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: glen herrmannsfeldt
- Re: Kind of NOT integer constant
- From: Richard Maine
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: Richard Maine
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: *** Hendrickson
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: Richard Maine
- Re: Kind of NOT integer constant
- From: James Giles
- Re: Kind of NOT integer constant
- From: Jan Vorbrüggen
- Re: Kind of NOT integer constant
- Prev by Date: Re: How to detect NULL input?
- Next by Date: Re: Does the order of declarations matter?
- Previous by thread: Re: Kind of NOT integer constant
- Next by thread: Re: Kind of NOT integer constant
- Index(es):