double type I got 0.199999999 when I supposed it to be 0.2, how to resolve it?

when I am doing some calculation, the floating point become 0.19999999 which I need it to be 0.2. How to resolve it plz.
Floating point types are weird and strange; they have discrete values.

The answer to your question depends on how you calculate and how you will use the result. You didn't tell those details yet.
0.210 cannot be stored exactly in binary; it is 0.00110011...2 with 0011 portion repeating. So that value cannot be stored in a floating point variable.
If you really need that .0000000000000000000000000000001 then you might want to invest in making your own floating class with strings or any way you really want or possibly looking for a library that has a more precise one such as boost.
Topic archived. No new replies allowed.