Home > Backend Development > PHP Tutorial > 判断整数_PHP

判断整数_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 12:30:27
Original
1147 people have browsed it



判断整数



 function checkInteger($Number)
 {
  if($Number > 1)
  {
   /* 整数减1仍然是整数 */
   return(checkInteger($Number-1));
  }
  elseif($Number   {
   /* 对于一个负数,*/
   /* 可以分析它的绝对值*/
   return(checkInteger((-1)*$Number-1));//取绝对值,把负数按整数分析
  }
  else
  {
   if(($Number > 0) AND ($Number    {
    return("当然不是");
   }
   else
   {
    /* 0 和 1 是整数       */
    /* 根据相关数学定义 */
    return("是的");
   }
  }
 }
 print("0是整数吗?" .
  checkInteger(0) . "
\n");
 print("7是整数吗? " .
  checkInteger(7) . "
\n");
 print("3.5呢?" . checkInteger(3.5) . "
\n");
 print("那么-5呢?" . checkInteger(-5) . "
\n");
 print("还有-9.2?" . checkInteger(-9.2) . "
\n");
?>


Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template