×

C++ Tutorial

C++ Data types

C++ Operators & Keywords

C++ Conditional Statements

C++ Functions

C++ 'this' Pointer, References

C++ Class & Objects

C++ Constructors & Destructors

C++ Operator overloading

C++ 11 (Advance C++)

C++ Preparation

C++ Header Files & Functionsr

Data Structure with C++

C++ - Miscellaneous

C++ Programs

C++ Math Functions (cmath Library)

C++ Math Functions

In C++ programming language, the <cmath> library provides various functions for mathematical operations on numbers.

The following table contains a list of <cmath> library (math functions):

Functions Description
fdim() Returns the positive difference between two numbers.
fmax() Returns the maximum value of the given numbers.
fmin() Returns the minimum value of the given numbers.
abs() Returns the absolute value of the given value.
acos() Returns the arc cosine value of the given value.
acosh() Returns the nonnegative area hyperbolic cosine of the given value.
isfinite() Checks whether the given value is finite value or not.
isgreater() Checks whether first value is greater than the second value.
isgreaterequal() Checks whether first value is greater than or equal to the second value.
isinf() Checks whether the given value is an infinite value.
isless() Checks whether first value is less than the second value.
islessequal() Checks whether first value is less than or equal to the second value.
islessgreater() Checks whether first value is either less than or greater than the second value.
isnan() Checks whether the given value is a NaN (Not-A-Number).
isnormal() Checks whether the given value is a normal value i.e. the value should not be infinity, NaN, Zero, or subnormal.
isunordered() Checks whether the given values are unordered (if one or both values are Not-A-Number (NaN)).
ldexp() Calculates the value from significand and exponent, it returns the multiplication of significand and 2 raised to the power of the exponent.
llrint() Rounds the given value and convert it to a long long integer.
llround() Rounds (with halfway cases) the given value and convert it to a long long integer.
log() Returns the natural logarithm (the base-e logarithm) of the given value.
log10() Returns the common logarithm (the base-10 logarithm) of the given value.
log1p() Returns the natural logarithm (the base-e logarithm) of the one plus given value.
log2() Returns the binary logarithm (the base-2 logarithm) of the given value.
logb() Returns the logarithm of |given value|, where logarithm base is FLT_RADIX (On the most of the platforms the FLT_RADIX is 2, thus, logb() function is similar to log2() function for the positive values.
lrint() Rounds the given value and convert it to a long integer.
lround() Round (with halfway cases) the given value and casts to a long integer.
modf() Breaks the fractional and integral parts of the given number.
nan() Returns a NaN (Not-A-Number) value of type double.
nanf() Returns a NaN (Not-A-Number) value of type float.
nanl() Returns a NaN (Not-A-Number) value of type long double.
nearbyint() Rounds the given value to an integral value.
nextafter() It is used to get the next representable value after the first parameter in the direction of the second parameter.
nexttoward() It is used to get the next representable value (toward precise value) after first parameter in the direction of the second parameter.
pow() It is used to calculate base (first parameter) raised to the power of exponent (second parameter).
remainder() It is used to calculate the remainder (IEC 60559).
remquo() It is used to calculate the remainder and quotient.
rint() It is used to round the given value to an integral values based on the specified direction by fegetround() function.
round() It is used to round the given value that is nearest to the number with halfway cases rounded away from zero.
scalbln() It scales the significand using floating-point base exponent (long int).
scalbn() It scales the significand using floating-point base exponent (int).
signbit() It is used to check the sign of the given value.
copysign() Returns first argument's value with the sign of the second argument.
 
 

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.