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.

x, y, z);<br />

errno = 0;<br />

x = 7.0;<br />

y = 0.0;<br />

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

if (errno)<br />

perror("Error");<br />

printf("For fmod(%f, %f) the remainder is %f\n\n",<br />

x, y, z);<br />

}<br />

Output:<br />

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

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

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

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

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

Error: domain error<br />

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

fmod (Continued)<br />

Standard C Libraries with Math Functions<br />

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

fmodf<br />

Description: Calculates the remainder of x/y as a single precision value.<br />

Include: <br />

Prototype: float fmodf(float x, float y);<br />

Arguments: x a single precision floating point value<br />

y a single precision floating point value<br />

Return Value: Returns the remainder of xdivided by y.<br />

Remarks: If y= 0, a domain error occurs. If yis nonzero, the result will have the<br />

same sign as xand the magnitude of the result will be less than the<br />

magnitude of y.<br />

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

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

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

int main(void)<br />

{<br />

float x,y,z;<br />

errno = 0;<br />

x = 7.0F;<br />

gồm) tới 1<br />

(Độc quyền). Không có lỗi miền orrange sẽ xảy ra.<br />

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

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

int main (void)<br />

{<br />

float x, y;<br />

int n;<br />

frexp (Tiếp theo)<br />

dsPIC<br />

®<br />

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

DS51456B trang 346 2004 Microchip Technology Inc<br />

x = 0.15F;<br />

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

printf ("Đối với frexpf của% f \ n phần là% f \ n",<br />

x, y);<br />

printf ("và số mũ là% d \ n \ n", n);<br />

x = -2.5F;<br />

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

printf ("Đối với frexpf của% f \ n phần là% f \ n",<br />

x, y);<br />

printf ("và số mũ là% d \ n \ n", n);<br />

x = 0.0f;<br />

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

printf ("Đối với frexpf của% f \ n phần là% f \ n",<br />

x, y);<br />

printf ("và số mũ là% d \ n \ n", n);<br />

}<br />

Đầu ra:<br />

Đối với frexpf của 0.150000<br />

phần là 0.600000<br />

và số mũ là -2<br />

Đối với frexpf của -2,500000<br />

phần là -,625000<br />

và số mũ là 2<br />

Đối với frexpf của 0.000000<br />

phần là 0.000000<br />

và số mũ là 0

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

Saved successfully!

Ooh no, something went wrong!