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.

ldexpf(-0.625000, 2) = -2.500000<br />

For a number = 2.500000 and an exponent = 3<br />

ldexpf(2.500000, 3) = 20.000000<br />

Error: range error<br />

For a number = 15.000000 and an exponent = 10000<br />

ldexpf(15.000000, 10000) = inf<br />

ldexpf (Continued)<br />

Standard C Libraries with Math Functions<br />

log<br />

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

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

point<br />

value.<br />

Include: <br />

Prototype: double log(double 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 />

NaN is<br />

returned if xis a negative number.<br />

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

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

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

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

int main(void)<br />

{<br />

double x, y;<br />

errno = 0;<br />

x = 2.0;<br />

y = log (x);<br />

if (errno)<br />

perror("Error");<br />

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

x, y);<br />

errno = 0;<br />

x = 0.0;<br />

y = log (x);<br />

if (errno)<br />

perror("Error");<br />

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

x, y);<br />

{<br />

float x, y;<br />

errno = 0;<br />

x = 2.0F;<br />

y = logf (x);<br />

if (errno)<br />

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

printf ("logarit tự nhiên của% f% f \ n \ n",<br />

x, y);<br />

errno = 0;<br />

x = 0.0f;<br />

y = logf (x);<br />

if (errno)<br />

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

printf ("logarit tự nhiên của% f% f \ n \ n",<br />

x, y);<br />

errno = 0;<br />

x = -2.0F;<br />

y = logf (x);<br />

if (errno)<br />

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

printf ("logarit tự nhiên của% f% f \ n \ n",<br />

x, y);<br />

}<br />

Đầu ra:<br />

Các of2.000000 logarit tự nhiên là 0,693147<br />

Logarit tự nhiên của 0.000000 là -INF<br />

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

Logarit tự nhiên của-2.000000 là nan<br />

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

2004 Microchip Technology Inc DS51456B trang 353<br />

modf<br />

Mô tả: Tách một độ chính xác kép nổi pointvalue vào phân đoạn và số nguyên<br />

các bộ phận.<br />

Bao gồm:<br />

Prototype: modf đôi (double x, double * pint);<br />

Đối số: x độ chính xác gấp đôi giá trị dấu chấm động<br />

pint con trỏ để lưu trữ một phần nguyên<br />

Quay trở lại giá trị: Trả về phần thập phân có chữ ký và pintpoints đến phần<br />

nguyên.

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

Saved successfully!

Ooh no, something went wrong!