--- layout: stdlib-reference --- # log2 ## Description Compute base-2 logarithm. ## Signature
/// Requires Capability Set 1:
T log2<T>(T x)
where T : __BuiltinFloatingPointType;
/// Requires Capability Set 1:
vector<T, N> log2<T, N:int>(vector<T, N> x)
where T : __BuiltinFloatingPointType;
/// Requires Capability Set 1:
matrix<T, N, M> log2<T, N:int, M:int>(matrix<T, N, M> x)
where T : __BuiltinFloatingPointType;
/// Requires Capability Set 2:
CoopVec<T, N> log2<T, N:int>(CoopVec<T, N> x)
where T : __BuiltinFloatingPointType;
## Generic Parameters
#### T: [\_\_BuiltinFloatingPointType](../interfaces/0_builtinfloatingpointtype-029hm/index.html)
#### N : int
#### M : int
## Parameters
#### x : [T](log2.html#typeparam-T)
The input value.
#### x : [vector](../types/vector/index.html)\<[T](../types/vector/index.html#typeparam-T), [N](../types/vector/index.html#decl-N)\>
The input value.
#### 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 input value.
#### x : [CoopVec](../types/coopvec-04/index.html)\<[T](../types/coopvec-04/index.html#typeparam-T), [N](../types/coopvec-04/index.html#decl-N)\>
The input value.
## Return value
The base-2 logarithm of x.
## Availability and Requirements
### Capability Set 1
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.
### Capability Set 2
Defined for the following targets:
#### hlsl
Available in all stages.
Requires capability: `hlsl_coopvec_poc`.
#### cpp
Available in all stages.
#### cuda
Available in all stages.
Requires capability: `optix_coopvec`.
#### spirv
Available in all stages.
Requires capability: `spvCooperativeVectorNV`.