powerof2 - Online Linux Manual PageSection : 3
Updated : 2022-12-31
Source : Linux man-pages 6.03

NAMEpowerof2 − test if a value is a power of 2

LIBRARYStandard C library (libc)

SYNOPSIS#include <sys/param.h>int powerof2(x);

DESCRIPTIONThis macro returns true if x is a power of 2, and false otherwise. 0 is considered a power of 2. This can make sense considering wrapping of unsigned integers, and has interesting properties.

RETURN VALUETrue or false, if x is a power of 2 or not, respectively.

STANDARDSThis nonstandard macro is present in glibc and the BSDs.

CAVEATSThe arguments may be evaluated more than once. Because this macro is implemented using bitwise operations, some negative values can invoke undefined behavior. For example, the following invokes undefined behavior: powerof2(INT_MIN);. Call it only with unsigned types to be safe.

SEE ALSOstdc_bit_ceil(3), stdc_bit_floor(3)
0
Johanes Gumabo
Data Size   :   3,915 byte
man-powerof2.3Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 204,408
Visitor ID   :     :  
Visitor IP   :   18.216.208.243   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.