Home > Article > Backend Development > [PHP] pow exponential operation function and binary conversion
1.a’s -2 power = (a/a) to the 2nd power
2.-a’s 2nd power and 3rd power According to this rule, negative and negative are positive, and negative and positive are negative, Positive is positive, if the exponent is an even number, the final result is positive, if it is an odd number, it is negative
3. Convert binary to decimal, starting with 0b is binary
<?php $a=pow(2,0);//int(1) $b=pow(-2,2);//int(4) $d=pow(-2,3);//int(-8) $c=pow(2,-2);//float(0.25) var_dump($d); //二进制转换十进制,0b开头是二进制 var_dump(0b0001);//2的0次方 1 pow(2,0) var_dump(0b0010);//2的1次方 2 pow(2,1) var_dump(0b0100);//2的2次方 4 pow(2,2) var_dump(0b1000);//2的3次方 8 pow(2,3)
[Recommended course :PHP video tutorial】
The above is the detailed content of [PHP] pow exponential operation function and binary conversion. For more information, please follow other related articles on the PHP Chinese website!