Your problem is neither new nor python specific but is inherent to floating point computations. All dynosaurus that once used Fortran 4 know it : you as the programmer have to know the expected precision ε of your computation. So :
- two numbers x and y are to be considered as equals if
| x - y | < ε
- the greatest integer inferior to x is
floor(x + ε)
- the least integer greater than x is
ceil(x - ε)
So your proposed solution is the good one, provided you have a way to know what is the good value for ε. If you are writing a module you should allow users to specify it.