$$% Arcus cosine. \def\acos{\cos^{-1}} % Vector projection. \def\projection#1#2{{proj_{#1}\left(#2\right)}} % Vector rejection. \def\rejection#1#2{{rej_{#1}\left(#2\right)}} % Norm. \def\norm#1{{\left\|#1\right\|}} % Cross product. \def\cross#1#2{\mathit{cross}\left(#1,#2\right)} % Dot product. \def\dot#1#2{{#1 \cdot #2}} % Magnitude. \def\mag#1{{\left|#1\right}} \def\group#1{\left(#1\right)}} \def\sbgrp#1{\left\{#1\right\}}$$

## Ring1_Intrinsic_nextPowerOfTwo

Compute the next power of two greater than or equal to an integer value.

 Ring1_Result Ring1_Intrinsic_nextPowerOfTwo_suffix   (     type *result,     type x   ) 

The following table denotes the valid combinations of suffix and type

 suffix type u8 uint8_t u16 uint16_t u32 uint32_t u64 uint64_t s8 int8_t s16 int16_t s32 int32_t s64 int64_t sz size_t

### Parameter variables

result
A pointer to a variable. result is assigned the next power of two greater than or equal to x on success. result is not dereferenced on failure.
x
The value.

### Return Values

Ring1_Result_Success on success, Ring1_Result_Failure on failure.

### Post Conditions

If this function fails, then it sets the by-thread status variable.

Below is a list of failure conditions and the status codes indicating them.

Ring1_Status_InvalidArgument
result was 0.
Ring1_Status_ArgumentOutOfRange
x is out of range.

### Remarks

The next power of two for a non-positive value is always 1.