Real life example for floating point error

Are there any examples of a company that was burnt with floating point data that caused a rounding issue? We are introducing a new system, and all monetary values ​​are stored in floats. I think that if I can show actual examples of why this failed, it will have more weight than the theory of why values ​​cannot be stored properly.

+5
source share
6 answers

These examples are taken from the embedded world (Ariane 5, Patriot), but are not stricto sensu floating point rounding errors. Ariane 5 Error - Error in conversion. Patriot bug was introduced during software adaptation. It includes calculations at different points with an inherent non-representable constant (which turns out to be harmless - 0.10).

There are two problems that I foresee with binary floats for monetary values:

  • decimal values ​​as common as 0.10 cannot be represented exactly.

  • If the accuracy is too low, then what could have been a pure overflow creating an exception becomes an inaccessible loss of accuracy.

, base-10 : 1 1000000 , , , , , , . , .

+3

, FPU ( ), testfloat level 3 , . fpus, , , ​​. , testfloat , fpu int, int, , pentium 4 . , III . , , . , , , , , , fpu. IEEE 754 , fpu , . c (atof, ftoa, strtod, printf ..) , .

float 23 , . . , , , . . , 9.99 15.99, , - , .

, , , 0,00 0,99, , , , .

- , , , ?

-, , fpu, , 1.0, , C . lsbit , .

+1

, , . - ( , , ), ( , ):

personal_bonus = * personal_bonus_percentage

department_bonus = personal_bonus * 50%

company_bonus = personal_bonus * 110%

total_bonus = personal_bonus + department_bonus + company_bonus

personal_bonus_percentage , , .

, ( ), , Excel . , , 5% .

0

, -, . , , , , . , , . .

, , , - . .

, . , . , , , . , , .

0
double: 1.000167890
single: 1.000167847
(b*(b-1)) - (b*b-b):  0.0000000281725079
(a*(a-1)) - (a*a-a):  0.0000000000000001
resultSmall - result: 0.000000028172507807931691
double^12 - single^12:0.000000593091349143648472

, - - , . , 13, , , .

IBM 360, 32- fp. a - b , , . , .

, .

0
source

All Articles