ceiling(x): Integer Ceiling

Integer ceiling function

Declaration

Syntax

retval = ceiling(x)
elemental integer function ceiling(x)

Arguments

The input value x may be of type real or integer.

Return values

The return value is of type integer and nearest greater integer.

Description

ceiling(x) returns the least integer greater than or equal to x.

Types

Supported input parameter types are integer and real.

interface ceiling
    module procedure sceiling, dceiling
end interface

contains

elemental integer function sceiling(x)
real(sp), intent(in) :: x
end function

elemental integer function dceiling(x)
real(dp), intent(in) :: x
end function

Examples

program intrinsics_ceiling
   implicit none
   real :: x = 63.29
   print *, ceiling(x)
   print *, ceiling(-63.29)
end program

Result:

64
-63

See Also

floor, mod.