c# - Why 0.3 - (3 * 0.10) = 5.4411512312578E-17? -
this question has answer here:
- understanding floating point problems 4 answers
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
Post a Comment