trunc, truncf, truncl, truncd32, truncd64, or truncd128 Subroutine

Purpose

Rounds to truncated integer value.

Syntax

#include <math.h>

double trunc (x)
double x;
float truncf (x)
float x;

long double truncl (x)
long double x;

_Decimal32 truncd32(x)
_Decimal32 x;
       
_Decimal64 truncd64(x)
_Decimal64 x;
       
_Decimal128 truncd128(x)
_Decimal128 x;

Description

The trunc, truncf, truncl, truncd32, truncd64, and truncd128 subroutines round the x parameter to the integer value, in floating format, nearest to but no larger in magnitude than the x parameter.

Parameters

Item Description
x Specifies the value to be rounded.

Return Values

Upon successful completion, the trunc, truncf, truncl, truncd32, truncd64, and truncd128 subroutines return the truncated integer value.

If x is NaN, a NaN is returned.

If x is ±0 or ±Inf, x is returned.