From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28844 invoked by alias); 4 Jan 2005 23:06:47 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 28657 invoked from network); 4 Jan 2005 23:06:34 -0000 Received: from unknown (HELO smtp109.mail.sc5.yahoo.com) (66.163.170.7) by sourceware.org with SMTP; 4 Jan 2005 23:06:34 -0000 Received: from unknown (HELO brianxp) (brian?desany@67.163.130.117 with login) by smtp109.mail.sc5.yahoo.com with SMTP; 4 Jan 2005 23:06:33 -0000 From: "Brian Desany" To: "'Andrew Cagney'" Cc: "'Peter Barada'" , Subject: RE: Quick question about "print EXPR" Date: Tue, 04 Jan 2005 23:06:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit In-Reply-To: <41DAFBF3.2060704@gnu.org> X-SW-Source: 2005-01/txt/msg00038.txt.bz2 Message-ID: <20050104230600.XPx1FlGEoFRwq8_GsyuIO_VxuTN6yjFYrMIPvpMg7Rs@z> > Brian Desany wrote: > >>Did you include in your program? > > > > > > Yep, I did (the program itself works properly). > > > > FWIW the only lines of the program that aren't listed in my > original post are: > > #include > > #include > > > > And just in case it matters, I compiled using the command > "cc -lm -g test.c". > > If I compile with "gcc -lm -g test.c", "p floor(whatever)" > is always > > 16 (rather than 1 as in the original post). > > Wonder if GDB can see this. What does: > > (gdb) ptype floor > > print? type = int () I was wrong about "p floor(whatever)" always returning a constant value. It returns a different value depending apparently on what line of the program I'm currently stopped on: Breakpoint 1, main (argc=1, argv=0xbfffcf54) at test.c:9 9 yada = 2.5; (gdb) p floor(123.456) $1 = 0 (gdb) n 10 haha = floor(yada); (gdb) p floor(123.456) $2 = 0 (gdb) n 11 printf("%0.1f %0.1f\n",yada, haha); (gdb) p floor(123.456) $3 = 3199 (gdb) n 2.5 -0.0 12 return 0; (gdb) p floor(123.456) $4 = 9 (gdb) > > Andrew > > > [bdesany]$ cc -v > > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs > > gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) > [bdesany]$ gcc > > -v Reading specs from > > /home/bdesany/sys/lib/gcc/i686-pc-linux-gnu/3.4.2/specs > > Configured with: ./configure --prefix=/home/bdesany/sys > Thread model: > > posix gcc version 3.4.2 > > > > Thanks- > > -Brian.