I'm trying to round decimal number to 2 decimals and I'm using String(format:"%.2f", number)
to achieve that.
Problem is that it is not consistent and sometimes it rounds number wrong.
For example it rounds 2.345
to 2.35
as it should, but it rounds 1.345
to 1.34
which is wrong, it should be 1.35
.
Does anyone know why is this happening and how to fix it?