From kde-devel Sun Jan 11 23:32:02 2004 From: Joachim Eibl Date: Sun, 11 Jan 2004 23:32:02 +0000 To: kde-devel Subject: Re: Open Bugs in 3.2 Message-Id: <200401120032.02805.joachim.eibl () gmx ! de> X-MARC-Message: https://marc.info/?l=kde-devel&m=107386413826082 > #include > int main() > { > long double a=49.84; > long double b=33.52; > long double c=a+b; > printf("%2.2llf + %2.2llf = %2.14llf\n",a,b,c); > } This little program contains a little surprise because you assign a double constant to a long double variable. Check this on your machine. long double a=49.84; // double constant printf("%2.30llf\n",a); // 49.840000000000003410605131648481 long double a1=49.84L; // long double constant printf("%2.30llf\n",a1); // 49.840000000000000000138777878078 This just illustrates how tricky it can be. BTW: There is no real general solution. You might just settle for a compromise like showing fewer digits. But it won't help you when you start subtracting almost equal numbers like: 1000.0000 - 1000.0001 etc. Cheers, Joachim >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<