0

Why cant i use mod operator to find remainder of a floating point no. Divided by any no even when we use floating point datatyp

ex when we use float c = 23.5%5; it shows error

19th Aug 2017, 2:25 AM
Harsh Wellengsly
Harsh Wellengsly - avatar
2 odpowiedzi
+ 16
if you use a 32Bit system and a unsigned float and you know that the first 16 Bit are used for the Numbers before the dot and the other 16 Bit are used for the rest, you can use the folliwing function/code: float myNum = 2.345; float rest = 0.0; rest = myNum && #0000FFFF; cout << rest; in this case you used a mask to filter the first part, that is stored in the first 16 Bit.
10th Oct 2017, 7:48 PM
Worm
Worm - avatar
+ 2
Modulus is only for integer types, at least in C++. I believe that fmod() is the function for float modulus.
19th Aug 2017, 2:39 AM
Keto Z
Keto Z - avatar