I have a situation when the classic representation error in Python started to be a problem: I need them to be used for Matrix operations in Numpy and the decimal type is not supported yet.
You all know that if I do 111.85 * 111.85
I will get 12510.422499999999
but if I round(12510.422499999999, 4)
I can get the proper result which is of course 12510.4225
.
But the actual questions are:
- Is this round stuff a good idea and a good practice?
- Will this work for all cases? sometimes the decimals position where the ..999 decimals could be more
- And finally, How to get the appropriate number of decimal positions to use with the round for all possible values?