From kde-devel Mon Jan 12 07:27:12 2004 From: Joachim Eibl Date: Mon, 12 Jan 2004 07:27:12 +0000 To: kde-devel Subject: Re: Open Bugs in 3.2 Message-Id: <200401120827.13050.joachim.eibl () gmx ! de> X-MARC-Message: https://marc.info/?l=kde-devel&m=107389367513645 Just another thought: When dealing with floating point numbers, we should use a floating point representation ("%g"). Not assuming fixed point ("%f"). That's where the trouble starts, because big numbers have fever valid digits after the comma. See the program below, followed by its output. Cheers, Joachim /* /usr/lib/gcc-lib/i586-suse-linux/3.3.1/include/float.h */ #include #include #include int main() { long double a = 0.0001L; // 0.0001 long double b = 1000.0001L; // 100.0001 long double c = b - 1000.0L - a; // 0 printf("%2.30Lf\n",a); printf("%2.30Lf\n",b); printf("%2.30Lf\n",c); printf("\n"); printf("%*.*Lg\n", LDBL_DIG+8, LDBL_DIG, a); printf("%*.*Lg\n", LDBL_DIG+8, LDBL_DIG, b); printf("%*.*Lg\n", LDBL_DIG+8, LDBL_DIG, c); } Output on my machine: 0.000100000000000000000001143494 1000.000099999999999988986587595718 -0.000000000000000011013413547776 0.0001 1000.0001 -1.10134135477760317e-17 >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<