uTools-Manuals/docs/c/fabs.html
2019-04-21 11:50:48 +08:00

39 lines
835 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1>数学函数 - fabs</h1>
<p>原型extern float fabs(float x);</p>
<p>用法:#include &lt;math.h></p>
<p>功能求浮点数x的绝对值</p>
<p>说明:计算|x|, 当x不为负时返回x否则返回-x</p>
举例:<pre><code class="language-c">
// fabs.c
#include &lt;syslib.h>
#include &lt;math.h>
main()
{
float x;
clrscr(); // clear screen
textmode(0x00); // 6 lines per LCD screen
x=-74.12;
printf("|%f|=%f\n",x,fabs(x));
x=0;
printf("|%f|=%f\n",x,fabs(x));
x=74.12;
printf("|%f|=%f\n",x,fabs(x));
getchar();
return 0;
}
</code></pre>相关函数:<a href="abs.html">abs</a>