mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-10-10 16:33:23 +08:00
0.0.1
This commit is contained in:
38
docs/c/fabs.html
Normal file
38
docs/c/fabs.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<h1>数学函数 - fabs</h1>
|
||||
|
||||
|
||||
<p>原型:extern float fabs(float x);</p>
|
||||
|
||||
<p>用法:#include <math.h></p>
|
||||
|
||||
<p>功能:求浮点数x的绝对值</p>
|
||||
|
||||
<p>说明:计算|x|, 当x不为负时返回x,否则返回-x</p>
|
||||
|
||||
举例:<pre>
|
||||
|
||||
// fabs.c
|
||||
|
||||
#include <syslib.h>
|
||||
#include <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;
|
||||
}
|
||||
|
||||
</pre>相关函数:<a href="abs.html">abs</a>
|
||||
|
Reference in New Issue
Block a user