Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Real numbers have not, in general a finite binary representation. Therefore, the finite binary representation that you get by default when you type "152.8" is an _approximation_ of the real that you could represent exactly by using "1528/10'.

BTW :

    sage: QQ(152.8)-QQ(152.43)
   37/100
   sage: (15280/100-15243/100)
    37/100
    sage: (15280/100-15243/100).n()
    0.370000000000000
    sage: (152.8-152.43)-(15280/100-15243/100)
    4.55191440096314e-15

which is compatible with the precision of the default binary representation of floats. If you want exact computations, use exact representations (which may or may not be finite...) : rationals, continued fractions. You can also use non-default representations with arbitrary representations.

HTH,