I have an array of type double and length which is supposed to save the following values: {0.3, 0.1, 0.8}. But when I check in the actual values in VS2013 debugger they are:
{0.29999999999999999, 0.10000000000000001, 0.80000000000000004}
In my application, these values are multiplied by some large numbers and then changed into integers to be used as index of another array, but the problem is because of the those trialing decimal numbers I end up with getting false results. I have tried to use the round(100*number)/100 method to extract the two decimal numbers but i didn't make difference. I was wondering how can avoid this problem? There are similar questions, but all I found was about displaying the numbers not actually using them in computations.
Aucun commentaire:
Enregistrer un commentaire