C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Math trunc()The function rounds off the given value towards zero and returns the nearest integral value whose magnitude is not greater than the given value. For example: trunc(3.8) = 3; SyntaxSuppose a number is 'x'. Syntax would be : return_type trunc(data_type x); Note: return_type can be float,double or long double.Parameterx: The value that can be float,double or long double. Return valueIt returns a rounded value of x. Example 1Let's see a simple example when the value of x is positive. #include Output: The value of x is :8.8 Truncated value of x is :8 Example 2Let's see a simple example when the value of x is negative. #include Output: The value of x is :-3.9 Truncated value of x is:-3
Next TopicC++ Math Functions
|