I have a weird problem, when using math expression in ng-bind the result are unexpected. Based on my experiment, the problem only happen when the first part of summand are 15 above and second part are 1.112 only.
ng-bind=”sum = 16 + 1.112″ ng-model=”sum” value=”16.112000000000002″
That’s a standard floating point rounding issue. The floating point numbers are represented in base 2, so most finite decimal fractions have no exact representation as (binary) floating point numbers. JavaScript uses IEEE754 double precision numbers with 53 bits of precision, the closest number to 1.112 is then
adding 15 to that needs more than 53 bits to represent the significand, so it must be rounded, the result is
and that is larger than the closest IEEE754 double precision number to 16.112, which is
and thus the first nonzero digit after the 16.112 is displayed to distinguish it from the closest number to 16.112