编程学问
  • 文章
  • 问题
  • 读书
  • 关于
  • 登录
  • « Math 函数
  • acos »
  • PHP Manual
  • Math 函数
  • 绝对值

abs

(PHP 4, PHP 5, PHP 7)

abs — 绝对值

说明

abs ( mixed $number ) : number

返回参数 number 的绝对值。

参数

number

要处理的数字值

返回值

number 的绝对值。 如果参数 number 是 float,则返回的类型也是 float,否则返回 integer(因为 float 通常比 integer 有更大的取值范围)。

范例

Example #1 abs() 例子

<?php
$abs 
= abs(-4.2); // $abs = 4.2; (double/float)
$abs2 = abs(5);   // $abs2 = 5; (integer)
$abs3 = abs(-5);  // $abs3 = 5; (integer)
?>

参见

  • gmp_abs() - Absolute value
  • gmp_sign() - Sign of number

相关文章
php math 函数 绝对值php math 函数 反双曲正切php math 函数 在任意进制之间转换数字php math 函数 十进制转换为十六进制php math 函数 十进制转换为八进制php math 函数 计算 e 的指数php math 函数 显示随机数最大的可能值php math 函数 十六进制转换为十进制php math 函数 对除法结果取整php math 函数 判断是否为有限值php math 函数 判断是否为无限值php math 函数 自然对数php math 函数 以 10 为底的对数php math 函数 返回 log 1 + number ,甚至当 number 的值接近零也能计算出准确结果php math 函数 找出最大值php math 函数 找出最小值php math 函数 指数表达式php math 函数 产生一个随机整数php math 函数 对浮点数进行四舍五入php math math 函数
关注编程学问公众号
编程学问网 湘ICP备20001732号