abs()

[Math]

描述

Computes the absolute value of a number.

語法

abs(x)

參數

X: the number

回傳

X: if X is greater than or equal to 0.
-x: if X is less than 0.

Warning

Because of the way the abs() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results.

abs(a++);   // avoid this - yields incorrect results
 
a++;          // use this instead -
abs(a);       // keep other math outside the function

語法參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール