This function is also used to return the remainder(modulus) of 2 floating point numbers mentioned in its arguments.The quotient computed is rounded.
remainder = number – rquot * denom
Where rquot is the result of: numer/denom, rounded toward the nearest integral value (with halfway cases rounded toward the even number).
double remainder(double a, double b) float remainder(float a, float b) long double remainder(long double a, long double b) Parameter: a and b are the values of numerator and denominator. Return: The remainder() function returns the floating point remainder of numerator/denominator rounded to nearest.
Error or Exception : It is mandatory to give both the arguments otherwise it will give error – no matching function for call to ‘remainder()’ like this.
# CODE 1
Remainder of 50.35/-4.1 is 1.15 Remainder of 16.8/3.5 is -0.7 Remainder of 16.8/0 is -nan
# CODE 2
Remainder of 50/41.35 = 8.65
- C++ Floating Point Manipulation (fmod(), remainder(), remquo() ... in cmath)
- OR Gate using Perceptron Network
- PImpl Idiom in C++ with Examples
- dot (.) operator in C/C++
- Features and Use of Pointers in C/C++
- Difference between while and do-while loop in C, C++, Java
- boost::algorithm::any_of_equal() in C++ library
- boost::algorithm::none_of_equal() in C++ library
- boost::algorithm::all_of_equal() in C++ library
- boost::algorithm::any_of() in C++ library
- Convert character array to string in C++
- Remove duplicates from a string using STL in C++
- std::string::back() in C++ with Examples
- std::string::front() in C++with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.