Ask Your Question

Revision history [back]

Short anwser :

sage: a = 1699./2^10 - 1
sage: a > 0.5
True

As 0.6591796875 is very far from 0.5, there is no issue here. But if the number are closer to eachother, and could be equal, you have to use more robust methods than raw floating-point nunbers. The right choice of numbers depends on your application, so you should provide more details.

Short anwser :

sage: a = 1699./2^10 - 1
sage: a > 0.5
True

As 0.6591796875 is very far from 0.5, there is no issue here. But if the number are closer to eachother, and could be equal, you have to use more robust methods than raw floating-point nunbers. The right choice of numbers depends on your application, so you should provide more details.

To learn more about the various representations of real numbers, let me suggest to read the following worksheet : https://mathexp2018.metelu.net/worksheets/real_and_complex_numbers/real_and_complex_numbers.ipynb