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.

perror("Error");<br />

printf("%f raised to %f is%f\n\n ", x, y, z);<br />

}<br />

Output:<br />

-2.000000 raised to 3.000000 is -8.000000<br />

3.000000 raised to -0.500000 is 0.577350<br />

Error: domain error<br />

0.000000 raised to -3.000000 is inf<br />

Standard C Libraries with Math Functions<br />

sin<br />

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

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

floating<br />

point value.<br />

Include: <br />

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

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

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

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

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

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

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

int main(void)<br />

{<br />

double x, y;<br />

errno = 0;<br />

x = -1.0;<br />

y = sin (x);<br />

if (errno)<br />

perror("Error");<br />

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

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

int main (void)<br />

{<br />

double x, y;<br />

errno = 0;<br />

x = 0,0;<br />

y = sqrt (x);<br />

if (errno)<br />

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

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

errno = 0;<br />

x = 9,5;<br />

y = sqrt (x);<br />

if (errno)<br />

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

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

errno = 0;<br />

x = -25,0;<br />

y = sqrt (x);<br />

if (errno)<br />

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

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

}<br />

Đầu ra:<br />

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

Căn bậc hai của 9.500000 là 3.082207<br />

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

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

dsPIC<br />

®<br />

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

errno = 0;<br />

x = 0.0;<br />

DS51456B trang 362<br />

sqrtf<br />

2004 Microchip Technology Inc<br />

y = sin (x);<br />

if (errno)<br />

perror("Error");<br />

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

}<br />

Output:<br />

Mô tả: Tính căn bậc hai của một giá trị chính xác điểm nổi duy nhất.<br />

Bao gồm:<br />

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

Đối số: x không âm giá trị dấu chấm<br />

Quay trở lại giá trị: Trả về căn bậc hai không âm của x.<br />

Ghi chú: Nếu XIS tiêu cực, một lỗi miền xảy ra.

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

Saved successfully!

Ooh no, something went wrong!