std::trunc

From cppreference.com
< cpp‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Exponential functions
(C++11)
(C++11)
(C++11)
(C++11)
Power functions
(C++11)
(C++11)
Trigonometric and hyperbolic functions
(C++11)
(C++11)
(C++11)
Error and gamma functions
(C++11)
(C++11)
(C++11)
(C++11)
Nearest integer floating point operations
(C++11)(C++11)(C++11)
trunc
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Floating point manipulation functions
(C++11)(C++11)
(C++11)
(C++11)
(C++11)(C++11)
(C++11)
Classification/Comparison
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Macro constants
(C++11)(C++11)(C++11)(C++11)(C++11)
 
Defined in header <cmath>
float       trunc( float arg );
(since C++11)
double      trunc( double arg );
(since C++11)
long double trunc( long double arg );
(since C++11)
double      trunc( Integral arg );
(since C++11)

Computes nearest integer not greater in magnitude than arg.

Contents

[edit] Parameters

arg - floating point value

[edit] Return value

Nearest integer not greater in magnitude than arg.

Return value
math-trunc.svg
Argument

[edit] Notes

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

[edit] See also

nearest integer not greater than the given value
(function)
nearest integer not less than the given value
(function)
(C++11)(C++11)(C++11)
nearest integer, rounding away from zero in halfway cases
(function)