| New Reply |
Another simple fortran q |
Share Thread | Thread Tools |
| Sep26-12, 05:24 PM | #1 |
|
|
Another simple fortran q
I want to find a bound for around magnitude 10**270 which is within bounds of double precision but I get
DOUBLE PRECISION :: bound = 10**270 Error: Arithmetic overflow at (1) .\q2.f03:70.4: where 1 is beneath the first *. I am sure it is something simple I am overlooking.... |
| PhysOrg.com |
science news on PhysOrg.com >> Hong Kong launches first electric taxis >> Morocco to harness the wind in energy hunt >> Galaxy's Ring of Fire |
| Sep26-12, 05:41 PM | #2 |
Recognitions:
|
Since 10 and 270 are both integers, 10**270 is evaluated as an integer expression, and then the result is converted to double precision to assign it to the variable. You got the overflow because 10**270 can't be represetned as an integer value.
You could write 10.0d0 ** 270, or better, just 10.0d270. Note you must use a "d" exponent (not "e") in a constant to make it double precision. 10.0 ** 270 will still give an overflow, because 10.0 is a single precision constant and the maximum value that can be represented in single precision is about 1038. |
| New Reply |
| Thread Tools | |
Similar Threads for: Another simple fortran q
|
||||
| Thread | Forum | Replies | ||
| Simple fortran help | Programming & Comp Sci | 1 | ||
| Help with a very simple fortran program. | Programming & Comp Sci | 1 | ||
| Simple do-loop in Fortran. Please help ! | Programming & Comp Sci | 2 | ||
| Simple fortran error | Programming & Comp Sci | 2 | ||
| FORTRAN:Simple question | Programming & Comp Sci | 0 | ||