![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
#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#
Date: 2023-01-15 16:01 (UTC)Re: C#
Date: 2023-01-15 19:15 (UTC)Although it is slower
Re: C#
Date: 2023-01-15 20:40 (UTC)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
Date: 2023-01-15 21:11 (UTC)Результат:
no subject
Date: 2023-01-16 05:50 (UTC)Hex interface is a good workaround.
But it may be hard to convince end users to use hex interface, right?