首页 > 文档 > abs() 绝对值
2017
07-13

abs() 绝对值

名称:abs()

 

例子:

int a = abs(153);      // Sets ‘a’ to 153
int b = abs(-15);      // Sets ‘b’ to 15
float c = abs(12.234); // Sets ‘c’ to 12.234
float d = abs(-9.23);  // Sets ‘d’ to 9.23

 

描述:

计算一个数字的绝对值(大小)。一个数字的绝对值总是正值。

 

语法:

abs(n)

 

参数:

n int, or float: number to compute

 

返回:float or int



最后编辑:
作者:Hewes
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。