I simply need to know how I can detect repeating decimal expansion in floats.
Example:
0.123456789123456789
The repeating portion of the number would
I don't think that there's solution in general (at least, with float
/double
):
float
(or even double
);float
/double
are approximate values. E.g., here's a result of division (double)1/(double)97
:
0.010309278350515464
Indeed, it is a repeating decimal with 96 repeating digits in period. How to detect this, if you only have 18 digits after decimal point?
Even in decimal
there's not enough digits:
0.0103092783505154639175257732