multiplication of double with integer precision

后端 未结 5 941
难免孤独
难免孤独 2021-01-22 20:35

I have a double of 3.4. However, when I multiply it with 100, it gives 339 instead of 340. It seems to be caused by the precision of double. How could I get around this?

5条回答
  •  無奈伤痛
    2021-01-22 21:32

    If you need full precision, you might want to use something like Boost.Rational.

提交回复
热议问题