ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_pwroftwo.cpp File Reference
#include "dsp_common.h"
Include dependency graph for dsps_pwroftwo.cpp:

Go to the source code of this file.

Functions

bool dsp_is_power_of_two (int x)
 check power of two The function check if the argument is power of 2. The implementation use ANSI C and could be compiled and run on any platform
int dsp_power_of_two (int x)
 Power of two The function return power of 2 for values 2^N. The implementation use ANSI C and could be compiled and run on any platform.

Function Documentation

◆ dsp_is_power_of_two()

bool dsp_is_power_of_two ( int x)

check power of two The function check if the argument is power of 2. The implementation use ANSI C and could be compiled and run on any platform

Returns
  • true if x is power of two
  • false if no

Definition at line 17 of file dsps_pwroftwo.cpp.

18{
19 return (x != 0) && ((x & (x - 1)) == 0);
20}
float x[1024]
Definition test_fir.c:10

◆ dsp_power_of_two()

int dsp_power_of_two ( int x)

Power of two The function return power of 2 for values 2^N. The implementation use ANSI C and could be compiled and run on any platform.

Returns
  • power of two

Definition at line 22 of file dsps_pwroftwo.cpp.

23{
24 for (size_t i = 0; i < 32; i++) {
25 x = x >> 1;
26 if (0 == x) {
27 return i;
28 }
29 }
30 return 0;
31}