Floating Point Functions in C Standard Library

Question: What are Different Floating-Point Functions in Standard C Library?

Answer: Most of the floating-point functions defined in ‘math.h’ header take their arguments as double and return double values. These functions range from Trigonometric to Hyperbolic to Logarithmic and Exponential to Power functions to Floor, Ceiling, Absolute value and Remainder functions to String conversion functions.

String conversion functions under Floating-point category are similar to string conversion Functions under Integer category except that former returns converted value as type double while latter returns converted value as variant of type int.

Note also that domain error occurs if argument to a function isn’t within domain defined for that function. For example,

    power(-5, 3/4);

Notice that power() returns first argument, say x, raised to second argument, say y, i.e. ‘x ^ y’. Since logarithms could also be used to compute ‘x ^ y’, domain error occurs if either x is -ve or y is non-integer. When domain error occurs, function returns an error value defined by implementation, value EDOM is stored in errno.

advertisement
advertisement

A range error, ERANGE, occurs if return value is too large or too small to be represented in a double. HUGE_VAL, a double value defined in ‘math.h’ will be reported as range error if return value is too large to be represented in a double. Range error also occurs when result is too small to be represented in double. In this case function returns 0. In either case, ERANGE is stored in errno.

Sanfoundry Global Education & Learning Series – 1000 C Tutorials.

If you wish to look at all C Tutorials, go to C Tutorials.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.