Lahey Support
08-15-2003, 12:19 AM
At 12:32 AM 1/23/99 PST, cosine Cheng wrote:
>Dear All:
>
> I wrote a small code and met some strange things...
>
>program test
> implicit none
> real :: a
>
> a = .123456
> a = a*10**10
Try
a = (a*10)**10
or
a = a*10.0**10
I'm pretty sure exponentiation is performed before multiplication.
The integer 10**10 is larger than the largest integer available in
32 bits (lahey's default integer size) which is 2**31 -1, a little
over 2,000,000,000. So, you are seeing the effects of integer overflow.
> WRITE(*,*) a
>...
>
> stop
>end program test
>
>The code replied me a strange # to a as: 0.174081E+09
>
>What's wrong with that? How to solve it out? By the way,
>
>if I use
>
> a = a*10**9
> WRITE(*,*) a ! <-- get 0.123456E+09
>
>
>or
>
> WRITE(*,*) .123456*10.**10 ! <-- get 0.123456E+10
>
>They worked well.
>
>Thanks
>
> Cosine
>Jan/23/1999 UT
>
>
>__________________________________________________ ____
>Get Your Private, Free Email at http://www.hotmail.com
>
>Dear All:
>
> I wrote a small code and met some strange things...
>
>program test
> implicit none
> real :: a
>
> a = .123456
> a = a*10**10
Try
a = (a*10)**10
or
a = a*10.0**10
I'm pretty sure exponentiation is performed before multiplication.
The integer 10**10 is larger than the largest integer available in
32 bits (lahey's default integer size) which is 2**31 -1, a little
over 2,000,000,000. So, you are seeing the effects of integer overflow.
> WRITE(*,*) a
>...
>
> stop
>end program test
>
>The code replied me a strange # to a as: 0.174081E+09
>
>What's wrong with that? How to solve it out? By the way,
>
>if I use
>
> a = a*10**9
> WRITE(*,*) a ! <-- get 0.123456E+09
>
>
>or
>
> WRITE(*,*) .123456*10.**10 ! <-- get 0.123456E+10
>
>They worked well.
>
>Thanks
>
> Cosine
>Jan/23/1999 UT
>
>
>__________________________________________________ ____
>Get Your Private, Free Email at http://www.hotmail.com
>