From: earnie_boyd AT yahoo DOT com (Earnie Boyd) Subject: Re: cygwin-b20 gcc: "A - floor(A)" returns a negative value 11 Nov 1998 11:48:04 -0800 Message-ID: <19981110143045.1359.rocketmail.cygnus.gnu-win32@send101.yahoomail.com> Reply-To: earnie_boyd AT yahoo DOT com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: Peter Kabal , gnu-win32 AT cygnus DOT com Hi Peter, Although your example indeed shows a potential bug in the optimizer IMHO your example is a little buggy itself. I believe your intent with the printf is to show the values that gave you the result and to do this you need two variables. When I modified your example to use two variables, AV1 and AV2, the result was the same for all values of optimization. If this was not your intent then please forgive my claims. ---Peter Kabal wrote: > > Switching from cygwin-b19 to cygwin-b20 caused a C-routine to give > incorrect results. This was traced to a calculation (in double) of > "A - float(A)" which returns a negative value. By definition it should > always be positive. A short test program which demonstrates this > problem is included. If the program is further simplified, the problem > goes away. To exercise the bug, the program must be compiled with > optimization level -O3. > > % gcc -O3 tfloor.c -o tfloor > % ./tfloor > AV = 20, AV - floor(AV) = -1.11022e-15 > > ---------------- > #include > #include > > int > main (argc, argv) > int argc; > char *argv[]; > { > double AV; > > AV = 0.05; > AV = 1.0 / (AV - floor (AV)); > printf ("AV = %g, AV - floor(AV) = %g\n", AV, AV - floor(AV)); > > return 0; > }; > ---------------- > Peter Kabal kabal AT ECE DOT McGill DOT CA > Dept. Electrical & Computer Engineering > McGill University > - > For help on using this list (especially unsubscribing), send a message to > "gnu-win32-request AT cygnus DOT com" with one line of text: "help". > == - \\||// -------------o0O0--Earnie--0O0o-------------- -- earnie_boyd AT yahoo DOT com -- -- http://www.freeyellow.com/members5/gw32 -- ----------------ooo0O--O0ooo----------------- PS: Newbie's, you should visit my page. _________________________________________________________ DO YOU YAHOO!? Get your free @yahoo.com address at http://mail.yahoo.com - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".