Your expectation is rather unfounded if unfortunately all too common. You can only be sure that all non-integer real numbers have an infinite-length representation in a positional system in any base (see this answer).
A finite-length representation of a rational number exists only in certain bases. It happens that the rational number 525/1000 does not have finite-length representation in base 2; the representation in that base is 0.100001(1001). It has a finite-length representation in base 10 (among others).
The double{0.525}
has only an infinite length representation in base 10. The number 0.52500000000000002
is truncated to the number of decimal positions that cover the number of mantissa bits in IEEE-754 double precision binary representation.
Since a float
or double
is a positional representation in a base-2 system, you should expect that any non-integer real will need an infinite-length representation to be accurately represented, and only some will be able to be represented in a finite length.