Re: Kind of NOT integer constant
- From: "James Giles" <jamesgiles@xxxxxxxxxxxxxxxx>
- Date: Fri, 06 Jan 2006 22:15:07 GMT
Richard Maine wrote:
> James Giles <jamesgiles@xxxxxxxxxxxxxxxx> wrote:
>
>> Certainly for REALs, the definition
>> of "addition" pretty much can't be "the mathematical sum
>> of the operands".
>
> I believe that is the definition of "addition" for reals, but that the
> result of any operation giving a real includes an approximation. That
> is to say
>
> x = 2.0 + 2.0
>
> doesn't mean that x is assigned the sum (addition, if you will) of 2.0
> and 2.0. Instead it means that x is assigned an approximation to that
> sum. I still think that the addition referred to is the mathematical
> operation of addition, but that the computational result differs from
> that mathematical one.
The places describing addition as an operatior don't use the word
"approximation" (well, I can't find it on quick perusal). Even if it were
used, unless it was explicitly said *separately* for REALs, the word
would imply that integer arithmetic was an approximatrion: that the
computational result could differ from the mathematical one. If, without
the word "approximation", the defrinition of REAL addition is assumed
to allow the computational result to differ from the mathematical
result, isn't that the same for INTEGER add? Why not?
***
To get back on topic. On a 32-bit platform, is the processor
allowed to generate 2147483646 as the answer for (2147483647+
2147483645)/2, or must it not? If it's allowed, then is the processor
permited to carry extra precision on the intermediates? Or do you
think it got the answer by magic?
Suppose that i, j, and k are all 32-bit default integers, and li is
an extended precision integer (64-bit say). On most 32-bit
machiines, if I write:
i = 2147483647
j = 2147483645
k = i+j
print *,k
the answer printed is -4 (or an overflow message). Suppose the example
was:
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 processor *is* permitted to carry extra intermediate precision,
how is this different from the case where NOT is involved. The value
of i+j has the 32nd bit set. The type and KIND of i+j is default
INTEGER. Is the compiler that uses extra precision for arithmetic
expressions prohibited from doing the same for bit-wise operations?
--
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
.
- Follow-Ups:
- Re: Kind of NOT integer constant
- From: Jan Vorbrüggen
- Re: Kind of NOT integer constant
- From: Richard Maine
- Re: Kind of NOT integer constant
- References:
- Re: Kind of NOT integer constant
- From: glen herrmannsfeldt
- 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: 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
- Prev by Date: Re: MPI/Fortran95 incompatibility? Was - Re: Pass by reference in Fortran77 standard?
- Next by Date: Re: Array Efficiency Related
- Previous by thread: Re: Kind of NOT integer constant
- Next by thread: Re: Kind of NOT integer constant
- Index(es):