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 = 1.0E3F;<br />

y = expf (x);<br />

if (errno)<br />

perror("Error");<br />

printf("The exponential of %f is %f\n\n", x, y);<br />

errno = 0;<br />

x = -1.0E3F;<br />

y = expf (x);<br />

if (errno)<br />

perror("Error");<br />

printf("The exponential of %f is %f\n\n", x, y);<br />

}<br />

Output:<br />

The exponential of 1.000000 is 2.718282<br />

Error: range error<br />

The exponential of 1000.000000 is inf<br />

Error: range error<br />

The exponential of -1000.000000 is 0.000000<br />

Standard C Libraries with Math Functions<br />

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

fabs<br />

Description: Calculates the absolute value of a double precision floating point<br />

value.<br />

Include: <br />

Prototype: double fabs(double x);<br />

Argument: x floating point value for which toreturn the absolute value<br />

Return Value: Returns the absolute value of x. (A negative number is returned<br />

as<br />

positive, a positive number is unchanged.)<br />

Remarks: No domain or rangeerror will occur.<br />

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

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

int main(void)<br />

{<br />

double x, y;<br />

x = 1.75;<br />

y = fabs (x);<br />

printf("The absolute value of %f is %f\n", x, y);<br />

x = -1.5;<br />

if (errno)<br />

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

printf ("Đối với fmod (% f, f%) còn lại là% f \ n \ n",<br />

x, y, z);<br />

floorf (Tiếp theo)<br />

dsPIC<br />

®<br />

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

DS51456B trang 342 2004 Microchip Technology Inc<br />

errno = 0;<br />

x = 7,0;<br />

y = 7.0;<br />

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

if (errno)<br />

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

printf ("Đối với fmod (% f, f%) còn lại là% f \ n \ n",<br />

x, y, z);<br />

errno = 0;<br />

x = -5,0;<br />

y = 3,0;<br />

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

if (errno)<br />

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

printf ("Đối với fmod (% f, f%) còn lại là% f \ n \ n",<br />

x, y, z);<br />

errno = 0;<br />

x = 5,0;<br />

y = -3,0;<br />

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

if (errno)<br />

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

printf ("Đối với fmod (% f, f%) còn lại là% f \ n \ n",<br />

x, y, z);<br />

errno = 0;<br />

x = -5,0;<br />

y = -5,0;<br />

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

if (errno)<br />

perror ("Lỗi");

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

Saved successfully!

Ooh no, something went wrong!