In Fortran, I want to be able to round a large double precision float to the nearest integer. I attempt this as follows,
PROGRAM rounding
IMPLICIT NONE
INTEGER, PARAMETER :: DP = 8
REAL(KIND=DP) :: value
value = 12345678987.123456
print *, CEILING(value)
END PROGRAM ROUNDING
However, this does not output the correct answer, but instead gives -2147483648
. I appreciate that this is related to the nature and precision of floating points, but rounding a number like this seems a reasonable goal.
Can anyone point me in the right direction?