Re: ITERATION COUNT
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 07 May 2011 10:28:28 -0500
In article <4dc55ab8$0$99950$c30e37c6@xxxxxxxxxxxxxxxxxxxxxx>,
"robin" <robin51@xxxxxxxxxxxxxxxxxx> wrote:
Might be interesting to find out how the following is handled:
program test
real :: rk
integer :: i
rk = 0
do i = -huge(i)-1, huge(i)
rk = rk + 1
end do
print *, rk, ' iterations'
end program test
When compiled, it starts WWIII. :-)
I think there are three separate problems with this. First, the
lower value for i (-huge(i)-1) is outside of the range of integers
in the model. The fact that it can be represented on twos
complement hardware does not make it standard conforming. Second,
the trip count has the value 2*huge(i)+2, which cannot be
represented as an integer in either the model space or the hardware.
Finally, the value of i after termination of the loop is required to
be huge(i)+1, which cannot be represented in either the model space
or the hardware.
The other issue, of course, is that the expression rk=rk+1 begins to
round off well before the loop has completed. This depends on the
rounding mode, but for IEEE arithmetic it will happen either when rk
has the value 8388608.0, which is 1.0/epsilon(1.0), or 16777216.0
which is 2.0/epsilon(1.0). Once that value is reached, the
expression rk=rk+1 does not change the value of rk.
$.02 -Ron Shepard
.
- Follow-Ups:
- Re: ITERATION COUNT
- From: robin
- Re: ITERATION COUNT
- From: robin
- Re: ITERATION COUNT
- From: steve
- Re: ITERATION COUNT
- References:
- ITERATION COUNT
- From: robin
- ITERATION COUNT
- Prev by Date: ITERATION COUNT
- Next by Date: Re: storing an integer in a double precision
- Previous by thread: ITERATION COUNT
- Next by thread: Re: ITERATION COUNT
- Index(es):