Debian Codegraph @

doc/src/intrinsics/numeric/ceiling.md

raw
1 # ceiling(x): Integer Ceiling
2
3 Integer ceiling function
4
5 ## Declaration
6
7 ### Syntax
8
9 ```fortran
10 retval = ceiling(x)
11 elemental integer function ceiling(x)
12 ```
13
14 ### Arguments
15
16 The input value `x` may be of type real or integer.
17
18 ### Return values
19
20 The return value is of type integer and nearest greater integer.
21
22 ## Description
23
24 **ceiling(x)** returns the least integer greater than or equal to `x`.
25
26 ## Types
27
28 Supported input parameter types are integer and real.
29
30 ```fortran
31 interface ceiling
32 module procedure sceiling, dceiling
33 end interface
34
35 contains
36
37 elemental integer function sceiling(x)
38 real(sp), intent(in) :: x
39 end function
40
41 elemental integer function dceiling(x)
42 real(dp), intent(in) :: x
43 end function
44 ```
45
46 ## Examples
47
48 ```fortran
49 program intrinsics_ceiling
50 implicit none
51 real :: x = 63.29
52 print *, ceiling(x)
53 print *, ceiling(-63.29)
54 end program
55 ```
56
57 **Result:**
58
59 ```
60 64
61 -63
62 ```
63
64 ## See Also
65
66 [floor](floor.md), [mod](mod.md).