30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

if (errno)<br />

perror("Error");<br />

printf("The arctangent of %f/%f is %f\n\n",<br />

y, x, z);<br />

}<br />

Output:<br />

The arctangent of 2.000000/0.000000 is 1.570796<br />

The arctangent of 0.000000/-1.000000 is 3.141593<br />

Error: domain error<br />

The arctangent of 0.000000/0.000000 is nan<br />

atan2 (Continued)<br />

Standard C Libraries with Math Functions<br />

2004 Microchip Technology Inc. DS51456B-page 331<br />

atan2f<br />

Description: Calculates the trigonometric arc tangent function of y/x.<br />

Include: <br />

Prototype: float atan2f (float y, float x);<br />

Arguments: y y value for which to return the arc tangent<br />

x x value for which to return the arc tangent<br />

Return Value: Returns the arc tangent inradians in the range of-pi to pi with the<br />

quadrant determined by the signs of both parameters.<br />

Remarks: A domain error occurs if both xand yare zero or both xand yare<br />

+/- infinity.<br />

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

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

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

int main(void)<br />

{<br />

float x, y, z;<br />

errno = 0;<br />

x = 2.0F;<br />

y = 0.0F;<br />

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

if (errno)<br />

perror("Error");<br />

printf("The arctangent of %f/%f is %f\n\n",<br />

y, x, z);<br />

errno = 0;<br />

x = 0.0F;<br />

Thư viện Công cụ Ngôn ngữ<br />

DS51456B trang 334<br />

errno = 0;<br />

x = 0,0;<br />

y = cos (x);<br />

if (errno)<br />

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

printf ("cô sin của% f% f \ n \ n", x, y);<br />

}<br />

Đầu ra:<br />

Các cô sin của -1,000000 là 0,540302<br />

Các cô sin của 0.000000 là 1.000000<br />

cosf<br />

2004 Microchip Technology Inc<br />

Mô tả: Tính hàm cosin lượng giác của một độ chính xác đơn<br />

nổi giá trị điểm.<br />

Bao gồm:<br />

Prototype: cosf nổi (float x);<br />

Đối số: x giá trị mà toreturn cô sin<br />

Quay trở lại giá trị: Trả về cosin của xin radian trong phạm vi của -1 đến 1 bao<br />

gồm.<br />

Bình luận: Một lỗi miền sẽ xảy ra nếu XIS một NaN hoặc vô cùng.<br />

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

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

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

int main (void)<br />

{<br />

float x, y;<br />

errno = 0;<br />

x = -1.0F;<br />

y = cosf (x);<br />

if (errno)<br />

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

printf ("cô sin của% f% f \ n \ n", x, y);<br />

errno = 0;<br />

x = 0.0f;<br />

y = cosf (x);<br />

if (errno)<br />

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

printf ("cô sin của% f% f \ n \ n", x, y);<br />

}

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

Saved successfully!

Ooh no, something went wrong!