snap_float_to_nice_decimal(x: float, order_of_magnitude_difference=7) → float¶
If x is near to a nice decimal, this rounds it. E.g., given a number like 8.01399999999999214, we want to round it to 8.014. We do this by comparing what we get if we round coarsely to what we get if we round precisely, for where place_difference represents how much more precise the precise round is than the course round. If they’re the same, then we should be rounding.
x – number to snap
order_of_magnitude_difference – how many orders of magnitude we compare rounding across
the rounded value