判断整数_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 12:30:271142browse



判断整数



 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");
?>


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