--- layout: stdlib-reference --- # sign ## Description Extract sign of value. ## Signature
int sign<T>(T x)
    where T : __BuiltinSignedArithmeticType;

vector<int, N> sign<T, int N>(vector<T, N> x)
    where T : __BuiltinSignedArithmeticType;

matrix<int, N, M> sign<T, int N, int M>(matrix<T, N, M> x)
    where T : __BuiltinSignedArithmeticType;

## Generic Parameters #### T: \_\_BuiltinSignedArithmeticType #### N : int #### M : int ## Parameters #### x : [T](sign.html#typeparam-T) The value to extract the sign of. #### x : [vector](../types/vector/index.html)\<[T](../types/vector/index.html#typeparam-T), [N](../types/vector/index.html#decl-N)\> The value to extract the sign of. #### x : [matrix](../types/matrix/index.html)\<[T](../types/matrix/t-0.html), [N](../types/matrix/index.html#decl-N), [M](../types/matrix/index.html#decl-M)\> The value to extract the sign of. ## Return value -1 if x is negative, 0 if x is zero, and 1 if x is positive. ## Availability and Requirements Defined for the following targets: #### hlsl Available in all stages. #### glsl Available in all stages. #### cpp Available in all stages. #### cuda Available in all stages. #### metal Available in all stages. #### wgsl Available in all stages. #### spirv Available in all stages. #### llvm Available in all stages.