jeudi 25 février 2016

clean up value without rounding up or down

There is an input to my software for processing: float totalPurchased. I am coding with C++11/GCC/GDB/Linux.

The totalPurchase price informed is 14.92 as it is read from a file.

However, when the program runs, it shows 14.920001 out of no where. I don't want to round the value 14.92 to up 15.00 or down 14.00; the only thing I really need is to have the input right, without the compiler adding up things that does not exist as input.

The problem is that this 0.000001 is breaking a part the whole software calculation in the long run.

How to get rid of this 0.000001, and make sure that it appears the actual value that was read from the file into my float variable: 14.92?

All comments and suggestions are highly appreciated.

Aucun commentaire:

Enregistrer un commentaire