Name
trunc - returns largest integer not greater than a scalar or each
vector component.
Synopsis
float trunc(float x);
float1 trunc(float1 x);
float2 trunc(float2 x);
float3 trunc(float3 x);
float4 trunc(float4 x);
half trunc(half x);
half1 trunc(half1 x);
half2 trunc(half2 x);
half3 trunc(half3 x);
half4 trunc(half4 x);
fixed trunc(fixed x);
fixed1 trunc(fixed1 x);
fixed2 trunc(fixed2 x);
fixed3 trunc(fixed3 x);
fixed4 trunc(fixed4 x);
Parameters
- x
-
Vector or scalar which to truncate.
Description
Returns the integral value nearest to but no larger in magnitude than x.
Reference Implementation
trunc for a float3 vector could be implemented like this.
float3 trunc(float3 v)
{
float3 rv;
int i;
for (i=0; i<3; i++) {
float x = v[i];
rv[i] = x < 0 ? -floor(-x) : floor(x);
}
return rv;
}
Profile Support
trunc is supported in all profiles except fp20.
See Also
ceil, floor, round
|