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.

errno = 0;<br />

x = 2.0F;<br />

y = log10f(x);<br />

if (errno)<br />

perror("Error");<br />

printf("The base-10 logarithm of %f is %f\n\n",<br />

x, y);<br />

errno = 0;<br />

x = 0.0F;<br />

y = log10f(x);<br />

if (errno)<br />

perror("Error");<br />

printf("The base-10 logarithm of %f is %f\n\n",<br />

x, y);<br />

errno = 0;<br />

x = -2.0F;<br />

y = log10f(x);<br />

if (errno)<br />

perror("Error");<br />

printf("The base-10 logarithm of %f is %f\n\n",<br />

x, y);<br />

}<br />

Output:<br />

The base-10 logarithm of2.000000 is 0.301030<br />

Error: domain error<br />

The base-10 logarithm of0.000000 is -inf<br />

Error: domain error<br />

The base-10 logarithm of -2.000000 is nan<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

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

logf<br />

Description: Calculates the natural logarithm of a single precision floating point<br />

value.<br />

Include: <br />

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

Argument: x any positive value for which to return the log<br />

Return Value: Returns the natural logarithm of x. -infis returned if xis 0 and<br />

if (errno)<br />

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

printf ("% f% f nâng lên là% f \ n \ n", x, y, z);<br />

errno = 0;<br />

x = 3,0;<br />

y = -0,5;<br />

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

if (errno)<br />

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

printf ("% f% f nâng lên là% f \ n \ n", x, y, z);<br />

errno = 0;<br />

x = 4,0;<br />

y = 0.0;<br />

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

if (errno)<br />

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

printf ("% f% f nâng lên là% f \ n \ n", x, y, z);<br />

errno = 0;<br />

x = 0,0;<br />

y = -3,0;<br />

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

if (errno)<br />

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

printf ("% f% f nâng lên là% f \ n \ n", x, y, z);<br />

}<br />

Đầu ra:<br />

-2,000000 Nâng lên 3,000000 là -8,000000<br />

3.000000 nâng lên -,500000 là 0,577350<br />

4.000000 nâng lên là 0.000000 1.000000<br />

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

0.000000 nâng lên -3,000000 là inf<br />

dsPIC<br />

®<br />

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

DS51456B trang 356 2004 Microchip Technology Inc<br />

powf<br />

Mô tả: Tính x lũy thừa y.<br />

Bao gồm:<br />

Prototype: powf nổi (float x, float y);

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

Saved successfully!

Ooh no, something went wrong!