Entry tags:
За что математики не любят компьютерную арифметику
#include <stdio.h> int main () { if (-5.2 + 4.9 != -0.3) { printf("Oops!\n"); } if (4.8 - 6.1 != -1.3) { printf("Oops!\n"); } if (4.3 - 3.6 != 0.7) { printf("Oops!\n"); } }Это мне надо было простенький тестик сварганить по работе, суммировать плавающие числа, а оно вон как боком выскочило.
Re: C#
Re: C#
Re: C#
Although it is slower
Re: C#
I thought he meant representation/conversion of data to decimal string.
In any case, the primary way to deal with imprecision is not increasing precision, but replacing number equality comparison with [epsilon] range comparison.
no subject
Результат:
no subject
Hex interface is a good workaround.
But it may be hard to convince end users to use hex interface, right?