c# - Why 0.3 - (3 * 0.10) = 5.4411512312578E-17? -


this question has answer here:

i'm confused. code:

        console.writeline(mychanges + " ten method " +  (ten_num * ten));(this debug)         if ((mychanges - (ten_num * ten)) >= 0)         {          }else             print error message 

like mychannges = 0.3 ; ten = 0.1; ten_num = 3, when print (mychanges - (ten_num * ten)) equals 5.4411512312578e-17

why not 0? solutions?

this due rounding errors inherent floating point operations. see http://docs.oracle.com/cd/e19957-01/806-3568/ncg_goldberg.html details.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -