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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- C++ Floating Point Manipulation (fmod(), remainder(), remquo() ... in cmath)
- Learn C++ Programming Step by Step - A 20 Day Curriculum!
- Why do we need reference variables if we have pointers
- Similarities and Difference between Java and C++
- Macros and its types in C/C++
- How to find index of a given element in a Vector in C++
- Introduction to Complex Objects and Composition
- NULL undeclared error in C/C++ and how to resolve it
- std::remove_const in C++ with Examples
- Finding Median of unsorted Array in linear time using C++ STL
- Average of Cubes of first N natural numbers
- Top 10 Programming Languages for Blockchain Development
- Memory Allocation in Static Data Members in C++
- Exception header 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.