abs
Keywords: abs, NVIDIA, NVIDIA Cg Toolkit, Cg Toolkit, Shader, Shader Programming, GPU Shader Programming, GPU Program

> ## Name

> abs - returns absolute value of scalars and vectors.

> ## Synopsis

>     float  abs(float  a);
>     float1 abs(float1 a);
>     float2 abs(float2 a);
>     float3 abs(float3 a);
>     float4 abs(float4 a);

>     half   abs(half  a);
>     half1  abs(half1 a);
>     half2  abs(half2 a);
>     half3  abs(half3 a);
>     half4  abs(half4 a);

>     fixed  abs(fixed  a);
>     fixed1 abs(fixed1 a);
>     fixed2 abs(fixed2 a);
>     fixed3 abs(fixed3 a);
>     fixed4 abs(fixed4 a);

> ## Parameters

> a
>   Vector or scalar of which to determine the absolute value.

> ## Description

> Returns the absolute value of a scalar or vector.

> For vectors, the returned vector contains the absolute value of each element of the input vector.

> ## Reference Implementation

> abs for a float scalar could be implemented like this.

>     float abs(float a)
>     {
>       return max(-a, a);
>     }

> ## Profile Support

> abs is supported in all profiles.

> Support in the fp20 is limited.

> Consider abs to be free or extremely inexpensive.

> ## See Also

> max