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.

The sine of -1.000000 is -0.841471<br />

The sine of 0.000000 is 0.000000<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 358<br />

sinf<br />

2004 Microchip Technology Inc.<br />

Description: Calculates the trigonometric sine function of a single precision<br />

floating<br />

point value.<br />

Include: <br />

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

Argument: x value for which to return the sine<br />

Return Value: Returns the sin of xin radians in the ranges of -1 to 1 inclusive.<br />

Remarks: A domain error will occur if xis a NaN or infinity.<br />

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

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

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

int main(void)<br />

{<br />

float x, y;<br />

errno = 0;<br />

x = -1.0F;<br />

y = sinf (x);<br />

if (errno)<br />

perror("Error");<br />

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

errno = 0;<br />

x = 0.0F;<br />

y = sinf (x);<br />

if (errno)<br />

perror("Error");<br />

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

}<br />

Output:<br />

The sine of -1.000000 is -0.841471<br />

The sine of 0.000000 is 0.000000<br />

Standard C Libraries with Math Functions<br />

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

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

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

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

int main (void)<br />

{<br />

x đôi;<br />

errno = 0;<br />

x = sqrtf (0.0f);<br />

if (errno)<br />

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

printf ("căn bậc hai của 0.0f là% f \ n \ n", x);<br />

errno = 0;<br />

x = sqrtf (9.5F);<br />

if (errno)<br />

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

printf ("căn bậc hai của 9.5F là% f \ n \ n", x);<br />

errno = 0;<br />

x = sqrtf (-25.0F);<br />

if (errno)<br />

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

printf ("căn bậc hai của -25F là% f \ n", x);<br />

}<br />

Đầu ra:<br />

Căn bậc hai của 0.0f là 0.000000<br />

Căn bậc hai của 9.5F là 3,082207<br />

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

Căn bậc hai của -25F là nan<br />

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

2004 Microchip Technology Inc DS51456B trang 363<br />

tan<br />

Mô tả: Tính hàm lượng giác tiếp xúc của một độ chính xác kép<br />

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

Bao gồm:<br />

Prototype: đôi tan (double x);<br />

Đối số: x giá trị mà trả lại tang<br />

Quay trở lại giá trị: Trả về tang của xin radian.<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 tan * /<br />

# include / * Cho printf, perror * /

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

Saved successfully!

Ooh no, something went wrong!