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.

x, y);<br />

errno = 0;<br />

x = 0.0;<br />

y = log10 (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.0;<br />

y = log10 (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 />

The base-10 logarithm of 0.000000 is -inf<br />

Error: domain error<br />

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

Standard C Libraries with Math Functions<br />

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

log10f<br />

Description: Calculates the base-10 logarithm ofa single precision floating point<br />

value.<br />

Include: <br />

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

Argument: x any single precision floating point positive number<br />

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

NaN<br />

is returned if xis a negative number.<br />

Remarks: A domain error occurs if x ≤0.<br />

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

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

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

int main(void)<br />

{<br />

float x, y;<br />

int main (void)<br />

{<br />

float x, y, n;<br />

x = 0.707F;<br />

y = modff (x, & n);<br />

printf ("% f Đối với phần là% f \ n", x, y);<br />

printf ("và các số nguyên là 0.f% \ n \ n", n);<br />

x = -15.2121F;<br />

y = modff (x, & n);<br />

printf ("% f Đối với phần là% f \ n", x, y);<br />

printf ("và các số nguyên là 0.f% \ n \ n", n);<br />

}<br />

Đầu ra:<br />

Đối với 0.707000 phần là 0.707000<br />

và các số nguyên là 0<br />

Đối với -15,212100 phần là -,212100<br />

và các số nguyên là -15<br />

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

2004 Microchip Technology Inc DS51456B trang 355<br />

pow<br />

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

Bao gồm:<br />

Prototype: pow đôi (double x, double y);<br />

Đối số: x cơ sở<br />

mũ ythe<br />

Quay trở lại giá trị: Trả về xraised cho y sức mạnh (x ^ y).<br />

Ghi chú: Nếu YIS 0 powreturns 1 Nếu XIS 0.0 và YIS nhỏ hơn 0 powreturns in<br />

và một lỗi xảy ra miền. Nếu tràn kết quả hoặc underflows, một<br />

phạm vi lỗi xảy ra.<br />

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

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

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

int main (void)<br />

{<br />

double x, y, z;<br />

errno = 0;<br />

x = -2,0;<br />

y = 3,0;<br />

z = pow (x, y);

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

Saved successfully!

Ooh no, something went wrong!