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

> ## Name

> length - return scalar Euclidean length of a vector

> ## Synopsis

>     float length(float v);
>     float length(float1 v);
>     float length(float2 v);
>     float length(float3 v);
>     float length(float4 v);

>     half length(half v);
>     half length(half1 v);
>     half length(half2 v);
>     half length(half3 v);
>     half length(half4 v);

>     fixed length(fixed v);
>     fixed length(fixed1 v);
>     fixed length(fixed2 v);
>     fixed length(fixed3 v);
>     fixed length(fixed4 v);

> ## Parameters

> v
>   Vector of which to determine the length.

> ## Description

> Returns the Euclidean length of a vector.

> ## Reference Implementation

> length for a float3 vector could be implemented like this.

>     float length(float3 v)
>     {
>       return sqrt(dot(v,v));
>     }

> ## Profile Support

> length is supported in all profiles.

> Support in the fp20 is limited.

> ## See Also

> max, normalize, sqrt, dot