Message-ID: <005501c2871e$2a5b9990$0100a8c0@p4> From: "Andrew Cottrell" To: Subject: Weird ceil() and other results Date: Fri, 8 Nov 2002 22:57:47 +1100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1123 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1123 Reply-To: djgpp-workers AT delorie DOT com If I comment out the #include from the program below then the program compiles and links without any errors or warnings. The results are:- date = 52.680000 date = 51.680000 decimalPart = 1072705824.000000 wholePart = 1077938047.000000 down = 1077939071.000000 If I include the #inclue from the program below then the program compiles and links without any errors or warnings. The results are:- date = 52.680000 date = 51.680000 decimalPart = 0.680000 wholePart = 51.000000 down = 52.000000 These results are correct.... Does anyone know why I would get wrong results, but no error messages if I do not include math.h? I would have expected to get error messages indicating a problem rather than a bad exe. #include #include #include #include #include #include #include #include #include #include int main() { double date; double decimalPart = 0.0; double wholePart = 0.0; double down; date = 52.68; printf("date = %f\n", date); decimalPart = fmod( date, 1.0 ); date -= 1.0; wholePart = (double) floor( date); down = ceil(date); printf("date = %f\n", date); printf("decimalPart = %f\n", decimalPart); printf("wholePart = %f\n", wholePart); printf("down = %f\n", down); }