If you have tried to find the modulo of two double/float types, you will run into an error. Click here to read about this error on stack overflow. Essentially, the % operator is used for finding the modulo of two integers. You need to use the fmod() function if you need to find the modulo of two double/float types.
Error trying to find the modulo of two doubles using the % operator
To find the modulo of two doubles, import the "math.h" standard library and use the following syntax to find the modulo: fmod(number1, number2).
Modulo of two double types. Float types can work as well.
References:
- Understanding the modulo operator
- Understanding something more about the modulo operator
- Modulo vs Modulus
Thank you for reading and I hope this helps.


.png)

No comments:
Post a Comment