I am generating an array, which contains very similar but not equal values, due to float inaccuracies. Here are sample elements from the beginning of the array:
[1.6666666666651508, 1.6666666666651508, -0.9999999999990905, -0.6666666666660604, 1.6666666666651504, 0.0, 0.0, -1.6666666666651513, 0.0, 0.0, 0.0, 1.6666666666651493, 0.0, 1.6666666666651493, 1.6666666666697005, 3.3333333333302986, 3.333333333334846, 3.3333333333348536, 3.3333333333302986,...]
I want to slice these numbers at a fixed position to remove these (it is essential for my code in a bigger context, that those inaccuracies do not occur). I've tried to bitmask it with 0b111.1111111 (= 7.9921875)
, but apparantely python doesn't support the &
on floats. I've tried to shift them, convert them to integers and then to use &
, but I just can't get it done.
Now, I was wondering, if there is an easy way to bitmask floats, or if there is another way in python, to slice floats after a specific position or to fix this.