Home  >  Article  >  Backend Development  >  这样使用while循环很奇怪?解决思路

这样使用while循环很奇怪?解决思路

WBOY
WBOYOriginal
2016-06-13 10:15:14878browse

这样使用while循环很奇怪?

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->        $pnum=91;        $randNum=0;        while($pnum>18){                        $randNum=$pnum/2;            if($randNum


我的本意是想获取比18小的数字,
可是,得出的是45.5?

请问错在哪里?

------解决方案--------------------
while这样用:

$pnum = 91;
while($pnum >= 18){
$pnum /= 2;
}
echo $pnum;

------解决方案--------------------
死的不能在死的循环。
我的本意是想获取比18小的数字??你的这个是什么需求?有点糊涂

PHP code
 $pnum=91; $randNum=0; while($pnum>18){                 $randNum = $pnum = $pnum/2;     if($randNum
                 
              
              
        
            
Statement:
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