[PHP] pow exponential operation function and binary conversion

little bottle
Release: 2023-04-05 21:22:01
forward
2945 people have browsed it

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)
Copy after login

[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!

source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!