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.

perror("Error");<br />

printf("For fmodf (%f,%f) the remainder is"<br />

" %f\n\n", x, y, z);<br />

errno = 0;<br />

x = 7.0F;<br />

y = 7.0F;<br />

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

if (errno)<br />

perror("Error");<br />

printf("For fmodf (%f,%f) the remainder is"<br />

" %f\n\n", x, y, z);<br />

}<br />

Output:<br />

For fmodf (7.000000,3.000000) the remainder is 1.000000<br />

For fmodf (-5.000000, 3.000000) the remainder is -2.000000<br />

For fmodf (5.000000, -3.000000) the remainder is 2.000000<br />

For fmodf (5.000000, -5.000000) the remainder is 0.000000<br />

Error: domain error<br />

For fmodf (7.000000,0.000000) the remainder is nan<br />

For fmodf (7.000000,7.000000) the remainder is 0.000000<br />

frexp<br />

Description: Gets the fraction and the exponent ofa double precision floating<br />

point<br />

number.<br />

Include: <br />

Prototype: double frexp (double x, int *exp);<br />

Arguments: x floating point value for which to return the fraction and<br />

exponent<br />

*exp pointer to a stored integer exponent<br />

Return Value: Returns the fraction, exppoints to the exponent. If xis 0, the<br />

function<br />

returns 0 for both the fraction and exponent.<br />

Remarks: The absolute value of the fraction is in the range of 1/2 (inclusive) to<br />

1<br />

(exclusive). No domain or range error will occur.<br />

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

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

int main(void)<br />

{<br />

double x,y;<br />

x, n, y);<br />

errno = 0;<br />

x = 15,0;<br />

n = 10000;<br />

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

if (errno)<br />

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

printf ("Đối với một số =% fand một số mũ =% d \ n",<br />

x, n);<br />

printf ("ldexp (% f,% d) =% f \ n \ n",<br />

x, n, y);<br />

}<br />

Đầu ra:<br />

Đối với một số = -,625000 và một số mũ = 2<br />

ldexp (-,625000, 2) = -2,500000<br />

Đối với một số = 2.500000 và một số mũ = 3<br />

ldexp (2.500000, 3) = 20,000000<br />

Lỗi: lỗi phạm vi<br />

Đối với một số = 15.000000 và một số mũ = 10000<br />

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

ldexpf<br />

Mô tả: Tính toán kết quả của một số điểm chính xác đơn nổi<br />

nhân với số mũ của 2.<br />

Bao gồm:<br />

Prototype: ldexpf nổi (float x, int cũ);<br />

Đối số: x nổi giá trị điểm<br />

exinteger mũ<br />

Quay trở lại giá trị: Trả về x * 2 ^ cũ. Trên một tràn, ldexpreturns infand trên<br />

Van cân bằng, ldexpreturns 0.<br />

ldexp (Tiếp theo)<br />

dsPIC<br />

®<br />

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

DS51456B trang 348 2004 Microchip Technology Inc<br />

Bình luận: Một lỗi xảy ra trên phạm vi sẽ tràn hoặc tràn dưới.<br />

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

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

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

int main (void)

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

Saved successfully!

Ooh no, something went wrong!