From 4619fc43a1c1d7c087158a02393ad50a7cec12ad Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 30 Apr 2024 19:52:40 -0400 Subject: [PATCH] cwMath.cpp : Fixed isPowerOfTwo() to recognize 1 as a power of 2. --- cwMath.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cwMath.cpp b/cwMath.cpp index 9f855d3..d5a737a 100644 --- a/cwMath.cpp +++ b/cwMath.cpp @@ -93,7 +93,7 @@ void cw::math::doubleToX80(double val, unsigned char rate[10]) bool cw::math::isPowerOfTwo( unsigned x ) { - return !( (x < 2) || (x & (x-1)) ); + return x==1 || (!( (x < 2) || (x & (x-1)) )); } unsigned cw::math::nextPowerOfTwo( unsigned val )