Getting the mantissa would be very hard with modulus.
How do you multiply by 10 until there is no more decimal point ? |
If you keep multiplying by 10 eventually the mantissa will be 0. Basically something like:
a == 0.12345
0.12345 - 0 = 0.12345, the mantissa is not 0
a * 10 == 1.2345
1.2345 - 1 = 0.2345, the mantissa is not 0
a * 100 == 12.345
12.345 - 12 = 0.345, the mantissa is not 0
a * 1000 == 123.45
123.45 - 123 = 0.45, the mantissa is not 0
a * 10000 == 1234.5
1234.5 - 1234 = 0.5, the mantissa is not 0
a * 100000 = 12345.0
12345 - 12345 = 0.0, the mantissa is 0
Keep in mind that checking if the mantissa is equal to 0 you will need to use a very small threshold something like
double threshold = 0.00000000000001;