I will perform an operation on each element in [-0.32695389161796801, -0.31471406408825409, -0.31475407980700348] by first retaining 3 digits after the decimal point and then 2 digits after the decimal point, using round(round(-0.32695389161796801,3),2 ) way, I get [-0.33000000000000002, -0.32000000000000001, -0.32000000000000001], but what I want to get is [-0.33, -0.32, -0.32], thank you
When using Python to handle floating point numbers where precision is important, it is recommended to use the built-in Decimal library:
If you just want it to look "accurate", you can also use the string format method