From: Luis Machado <luisgpm@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: Re: GDB/libiberty support for IBM long double
Date: Fri, 28 Dec 2007 01:20:00 -0000 [thread overview]
Message-ID: <1198783208.7822.51.camel@gargoyle> (raw)
In-Reply-To: <Pine.LNX.4.64.0711130038330.29493@digraph.polyomino.org.uk>
Hi folks,
There appears to be a problem with the use of IBM long doubles. In
specific situations the values are being shown in a wrong way.
Follows an example of GDB HEAD:
(gdb) ptype ld0
type = long double
(gdb) p sizeof(ld0)
$8 = 16
(gdb) set ld0=1.2
(gdb) p ld0
$9 = 1.39999980921857059001922607421875
(gdb) printf "Long Double 128: %.30Lg \n",ld0
Long Double 128: 1.39999980921857059001922607422
(gdb) printf "Long Double 128: %.30Lg \n",1.2
Long Double 128: 1.19999999999999995559107901499
(gdb) printf "Long Double 128: %.30Lg \n",(long double)1.2
Long Double 128: 1.39999980921857059001922607422
(gdb)
The only correct value is when we don't have a value that is explicitly
a long double, in which case we have 1.19999999999999995559107901499.
I've tracked down the problem and it appears libiberty is doing wrong
calculations when we have a long double. In particular, this piece of
code from "floatformat_to_double:libiberty/floatformat.c:527":
===> code <====
if (exponent != 0)
exponent -= mant_bits;
===> code <====
We really need to be able to decrement EXPONENT (even if it's zero) to
get the right exponent value to call the ldexp(mant, exponent) function
for the next iteration, thus leading to a correct long double value.
Removing this condition fixes the problem, but i'm not sure this is 100%
safe as this condition must have a purpose.
Any ideas?
Best regards,
--
Luis Machado
Software Engineer
IBM Linux Technology Center
next prev parent reply other threads:[~2007-12-27 19:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-26 0:25 Joseph S. Myers
2007-10-26 0:37 ` DJ Delorie
2007-10-29 1:31 ` Joseph S. Myers
2007-11-05 22:33 ` Ping " Joseph S. Myers
2007-11-07 22:43 ` Daniel Jacobowitz
2007-11-07 23:26 ` DJ Delorie
2007-11-09 1:07 ` Ulrich Weigand
2007-11-13 0:39 ` Joseph S. Myers
2007-11-13 13:56 ` Ulrich Weigand
2007-11-13 14:37 ` Joseph S. Myers
2007-11-13 15:15 ` DJ Delorie
2007-11-13 17:58 ` Ulrich Weigand
2007-12-28 1:20 ` Luis Machado [this message]
2007-12-28 12:29 ` Andreas Schwab
2007-12-28 21:40 ` Luis Machado
2007-12-30 11:25 ` Daniel Jacobowitz
2008-01-02 16:17 ` Luis Machado
2008-01-02 17:01 ` Daniel Jacobowitz
2008-01-02 18:12 ` Luis Machado
2008-01-02 18:32 ` Daniel Jacobowitz
2008-01-03 11:47 ` Luis Machado
2007-10-26 8:05 ` Mark Kettenis
2007-10-26 15:01 ` Joseph S. Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1198783208.7822.51.camel@gargoyle \
--to=luisgpm@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox