- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code below results in "0 error(s), 0 warning(s)"
program test
implicit none
integer*4, parameter :: p = -2147483648
write(*, *) p
stop
end program test
and produces correct screen output ofthe left border of32-bit (signed, two's complement) integer value range-2,147,483,648 through 2,147,483,647
BUT the following code
program test
implicit none
integer*4, parameter :: p = -2147483648_4
write(*, *) p
stop
end program test
results in "Warning: The INTEGER(KIND=4) value is out-of-range. [2147483648]"
The screen output is still correct.
Please comment on this compiler behavior.
Thank you.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may think this is somewhat pedantic, but the value you supply is interpreted as a positive number, before it is negated. A common circumlocation would be (-2147483647_4 - 1_4). This avoids the trouble with the range of the number system.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page