Xref: news2.mv.net comp.os.msdos.djgpp:4632 From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Why doesnt this work! Date: Wed, 05 Jun 1996 11:31:18 +0100 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 36 Message-ID: <31B561F6.59E2@LSTM.Ruhr-UNI-Bochum.De> References: <4p5btk$5ic AT news DOT cybermax DOT net> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp blah (what a nick name...) wrote: > > Can anyone tell me why this code doesnt work in djgpp. > [...] > printf("The time was: %f\n", (end - start) / CLK_TCK); [...] > > When i run this after compiling in gcc it always prints 0.00000! > I compiled it with -> gcc timer.c -otimer.exe > When i compile in borland c 3.1 or microsoft c 1.0 it works fine and give the > expected result(some floating point number - about 2.?????) Well, you have only int operands, and the compiler sees no point why he should change the expression to a float. So, you're giving printf an int to print, not a float (double, actually). Just say something like (end -start) / (float ) CLK_TCK And remember: C isn't Pascal, there is no DIV, but / has a double meaning. A mistake I made myself often enough.... -- Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************