30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

y = fabs (x);<br />

printf("The absolute value of %f is %f\n", x, y);<br />

}<br />

Output:<br />

The absolute value of 1.750000 is 1.750000<br />

The absolute value of -1.500000 is 1.500000<br />

fabsf<br />

Description: Calculates the absolute value of a single precision floating point<br />

value.<br />

Include: <br />

Prototype: float fabsf(float x);<br />

Argument: x floating point value for which to return the absolute value<br />

Return Value: Returns the absolute value of x. (A negative number is returned<br />

as<br />

positive, a positive number is unchanged.)<br />

Remarks: No domain or rangeerror will occur.<br />

Example: #include /* for fabsf */<br />

#include /* for printf */<br />

int main(void)<br />

{<br />

float x,y;<br />

x = 1.75F;<br />

y = fabsf (x);<br />

printf("The absolute value of %f is %f\n", x, y);<br />

x = -1.5F;<br />

y = fabsf (x);<br />

printf("The absolute value of %f is %f\n", x, y);<br />

}<br />

Output:<br />

The absolute value of 1.750000 is 1.750000<br />

The absolute value of -1.500000 is 1.500000<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 340<br />

floor<br />

2004 Microchip Technology Inc.<br />

Description: Calculates the floor of a double precision floating point value.<br />

Include: <br />

Prototype: double floor (double x);<br />

Argument: x floating point value for which to return the floor.<br />

printf ("Đối với fmod (% f, f%) còn lại là% f \ n \ n",<br />

x, y, z);<br />

errno = 0;<br />

x = 7,0;<br />

y = 0.0;<br />

z = fmod (x, y);<br />

if (errno)<br />

perror ("Lỗi");<br />

printf ("Đối với fmod (% f, f%) còn lại là% f \ n \ n",<br />

x, y, z);<br />

}<br />

Đầu ra:<br />

Đối với fmod (7.000000, 3.000000) còn lại là 1.000000<br />

Đối với fmod (7.000000, 7.000000) còn lại là 0.000000<br />

Đối với fmod (-5,000000, 3,000000) còn lại là -2,000000<br />

Đối với fmod (5.000000, -3,000000) còn lại là 2,000000<br />

Đối với fmod (-5,000000, -5,000000) còn lại là -,000000<br />

Lỗi: lỗi miền<br />

Đối với fmod (7.000000, 0.000000) còn lại là nan<br />

fmod (Tiếp theo)<br />

Thư viện chuẩn C với hàm toán học<br />

2004 Microchip Technology Inc DS51456B trang 343<br />

fmodf<br />

Mô tả: Tính toán phần còn lại của x / y như một giá trị chính xác duy nhất.<br />

Bao gồm:<br />

Prototype: fmodf nổi (float x, float y);<br />

Đối số: xa đơn giá trị điểm chính xác nổi<br />

ya đơn chính xác nổi giá trị điểm<br />

Quay trở lại giá trị: Trả về phần còn lại của xdivided của y.<br />

Ghi chú: Nếu y = 0, một lỗi miền xảy ra. Nếu YIS khác không, kết quả sẽ có<br />

cùng dấu hiệu như xand tầm quan trọng của kết quả sẽ thấp hơn<br />

tầm quan trọng của y.<br />

Ví dụ: # include / * Cho fmodf * /<br />

# include / * Cho printf, perror * /<br />

# include / * Cho errno * /<br />

int main (void)<br />

{<br />

nổi x, y, z;<br />

errno = 0;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!