the following expression evaluates false
in c#:
(1 + 1 + 0.85) / 3 <= 0.95
and suppose in other programming languages implement ieee 754, since (1 + 1 + 0.85) / 3
evaluates 0.95000000000000007
, greater 0.95
.
however, though excel should implement of ieee 754 too, following evaluates true in excel 2013:
= ((1 + 1 + 0.85) / 3 <= 0.95)
is there specific reason that? article linked above not mention custom implementations of excel can lead behavior. can tell excel strictly round according ieee 754?
please note though excel questions should asked on superuser.com, question deals floating-point arithmetic, common problem in programming languages. viewpoint of question's topic, excel programming language c# or java.
the article linked explicit doing nonstandard values near 0:
example when value reaches 0 1.in excel 95 or earlier, enter following new workbook: a1: =1.333+1.225-1.333-1.225
2.right-click cell a1, , click format cells. on number tab, click scientific under category. set decimal places 15. instead of displaying 0, excel 95 displays -2.22044604925031e-16.
excel 97, however, introduced optimization attempts correct problem. should addition or subtraction operation result in value @ or close zero, excel 97 , later compensate error introduced result of converting operand , binary.
the unspecified "optimization attempts correct problem" mean caution should used in using excel numerical computations when strict agreement ieee 754 required. perhaps using vba (which unlikely have "optimization"?) might workaround.
Comments
Post a Comment