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