public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31006] New: long double constant is read as double in i386
@ 2007-03-01 7:59 chat95 at mac dot com
2007-03-01 8:00 ` [Bug c/31006] " chat95 at mac dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: chat95 at mac dot com @ 2007-03-01 7:59 UTC (permalink / raw)
To: gcc-bugs
when we #define PI 3.141592653589793238462643383279L
and long double a=PI;
PI is substituted in double precision.
--
Summary: long double constant is read as double in i386
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chat95 at mac dot com
GCC build triplet: i386-portbld-freebsd6.2
GCC host triplet: i386-portbld-freebsd6.2
GCC target triplet: i386-portbld-freebsd6.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31006
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/31006] long double constant is read as double in i386
2007-03-01 7:59 [Bug c/31006] New: long double constant is read as double in i386 chat95 at mac dot com
@ 2007-03-01 8:00 ` chat95 at mac dot com
2007-03-01 8:01 ` chat95 at mac dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: chat95 at mac dot com @ 2007-03-01 8:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from chat95 at mac dot com 2007-03-01 08:00 -------
Created an attachment (id=13129)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13129&action=view)
test case
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31006
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/31006] long double constant is read as double in i386
2007-03-01 7:59 [Bug c/31006] New: long double constant is read as double in i386 chat95 at mac dot com
2007-03-01 8:00 ` [Bug c/31006] " chat95 at mac dot com
@ 2007-03-01 8:01 ` chat95 at mac dot com
2007-03-01 8:06 ` chat95 at mac dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: chat95 at mac dot com @ 2007-03-01 8:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from chat95 at mac dot com 2007-03-01 08:01 -------
I used following compiler:
% gcc42 -v
Using built-in specs.
Target: i386-portbld-freebsd6.2
Configured with: ./..//gcc-4.2-20070110/configure --disable-nls
--with-system-zlib --with-libiconv-prefix=/usr/local --with-gmp=/usr/local
--program-suffix=42 --libdir=/usr/local/lib/gcc-4.2.0
--with-gxx-include-dir=/usr/local/lib/gcc-4.2.0/include/c++/
--infodir=/usr/local/info/gcc42 --disable-rpath --prefix=/usr/local
i386-portbld-freebsd6.2
Thread model: posix
gcc version 4.2.0 20070110 (prerelease)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31006
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/31006] long double constant is read as double in i386
2007-03-01 7:59 [Bug c/31006] New: long double constant is read as double in i386 chat95 at mac dot com
2007-03-01 8:00 ` [Bug c/31006] " chat95 at mac dot com
2007-03-01 8:01 ` chat95 at mac dot com
@ 2007-03-01 8:06 ` chat95 at mac dot com
2007-03-01 12:22 ` [Bug target/31006] " rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: chat95 at mac dot com @ 2007-03-01 8:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from chat95 at mac dot com 2007-03-01 08:06 -------
1.
// long double PI * PI + IP
ld_a = ld_b = PI;
part becomes:
movl $560513024, %eax
movl $-921707870, %edx
movl $16384, %ecx
This number is equivalent to:
0x4000c90fdaa22168c000
and we can write down as floating point number as:
2^(16384-16383) * 1.100100100001111 1101101010100010 0010000101101000
11000000000000 (B)
2.// double PI * PI + IP
d_a = d_b = PI;
part becomes:
movl $1413754136, %eax
movl $1074340347, %edx
this number is equivalent to:
0x400921fb54442d18,
and corresponding floating number is:
2^(1024-1023)* 1.1001001000011111101101010100010001000010110100011000(B)
.
when we compare these significants of these two numbers:
1.100100100001111 1101101010100010 0010000101101000 11000(B)
1.100100100001111 1101101010100010 0010000101101000 11000 000000000 (B)
so - what we can say from here is:
#define PI 3.14...L is read as double for long double number with 0 filled
lowest 16bits.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31006
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/31006] long double constant is read as double in i386
2007-03-01 7:59 [Bug c/31006] New: long double constant is read as double in i386 chat95 at mac dot com
` (2 preceding siblings ...)
2007-03-01 8:06 ` chat95 at mac dot com
@ 2007-03-01 12:22 ` rguenth at gcc dot gnu dot org
2007-03-01 12:27 ` rguenth at gcc dot gnu dot org
2009-09-17 12:46 ` ubizjak at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-01 12:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2007-03-01 12:22 -------
What is the expected output of your testcase?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31006
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/31006] long double constant is read as double in i386
2007-03-01 7:59 [Bug c/31006] New: long double constant is read as double in i386 chat95 at mac dot com
` (3 preceding siblings ...)
2007-03-01 12:22 ` [Bug target/31006] " rguenth at gcc dot gnu dot org
@ 2007-03-01 12:27 ` rguenth at gcc dot gnu dot org
2009-09-17 12:46 ` ubizjak at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-01 12:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2007-03-01 12:27 -------
With gcc 4.1.2 and your testcase fixed to use %f for the double argument printf
I get
rguenther@murzim:/tmp> gcc -o t t.c -m32
rguenther@murzim:/tmp> ./t
long double = 3.141592653589793238512808959406
long double - double double = +3.141592653589793115997963468544
rguenther@murzim:/tmp> gcc -o t t.c
rguenther@murzim:/tmp> ./t
long double = 3.141592653589793238512808959406
long double - double double = +3.141592653589793115997963468544
same for 4.2.0.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31006
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/31006] long double constant is read as double in i386
2007-03-01 7:59 [Bug c/31006] New: long double constant is read as double in i386 chat95 at mac dot com
` (4 preceding siblings ...)
2007-03-01 12:27 ` rguenth at gcc dot gnu dot org
@ 2009-09-17 12:46 ` ubizjak at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: ubizjak at gmail dot com @ 2009-09-17 12:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from ubizjak at gmail dot com 2009-09-17 12:46 -------
Your d_a is defined as double, so gcc truncates constant to fit in the "double"
value range. After that, you pass this double value as an argument to %Lf,
which is wrong. You should write:
printf("long double - double double = %+5.30Lf\n", (long double) d_a);
As far as your testcse is concerned, there is no error, truncation from long
double to double is what you requested with "double" intermediate register.
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31006
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-09-17 12:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-01 7:59 [Bug c/31006] New: long double constant is read as double in i386 chat95 at mac dot com
2007-03-01 8:00 ` [Bug c/31006] " chat95 at mac dot com
2007-03-01 8:01 ` chat95 at mac dot com
2007-03-01 8:06 ` chat95 at mac dot com
2007-03-01 12:22 ` [Bug target/31006] " rguenth at gcc dot gnu dot org
2007-03-01 12:27 ` rguenth at gcc dot gnu dot org
2009-09-17 12:46 ` ubizjak at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).