Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/numeric/math/ceil"

From cppreference.com
< cpp‎ | numeric‎ | math
(+plot)
(update plot)
Line 27: Line 27:
 
Nearest integer not less than {{tt|arg}}
 
Nearest integer not less than {{tt|arg}}
  
{{plot return | image=math-ceil.svg}}
+
{{plot | left="Return value" | bottom="Argument" | image=math-ceil.svg}}
  
 
===Notes===
 
===Notes===

Revision as of 11:39, 13 May 2012

Template:cpp/numeric/math/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <cmath>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
float       ceil( float arg );
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
double      ceil( double arg );
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
long double ceil( long double arg );
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
double      ceil( Integral arg );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

Computes nearest integer not less than arg.

Contents

Parameters

arg - floating point value

Return value

Nearest integer not less than arg

No image specified

Notes

The integer value can be always represented by the given floating point type.

Example

#include <cmath>
#include <iostream>
 
int main()
{
    double a = 12.0;
    std::cout << std::fixed;
    std::cout << std::ceil(12.0) << '\n';
    std::cout << std::ceil(12.1) << '\n';
    std::cout << std::ceil(12.5) << '\n';
    std::cout << std::ceil(12.9) << '\n';
    std::cout << std::ceil(13.0) << '\n';}

Output:

12.000000
13.000000
13.000000
13.000000
13.000000

See also

Template:cpp/numeric/math/dcl list floorTemplate:cpp/numeric/math/dcl list truncTemplate:cpp/numeric/math/dcl list round