public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/15019] New: Float and double math produces unexpected results.
@ 2004-04-20 4:03 gcc at paypc dot com
2004-04-20 4:25 ` [Bug c/15019] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: gcc at paypc dot com @ 2004-04-20 4:03 UTC (permalink / raw)
To: gcc-bugs
This problem occurs on both gcc-3.2.3 and gcc-3.3.3
For the gcc-3.2.3 compiler:
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared
--enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld
--verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.2.3
For the gcc-3.3.3 compiler:
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: ./configure --program-suffix=-3.3 --enable-languages=c,c++
--with-system-zlib --enable-threads --prefix=/usr
Thread model: posix
gcc version 3.3.3
On both systems GLIBC 2.3.2 is being used.
Code which triggers the bug:
build command line: gcc -o bugs bugs.c -lm
---------- SNIP -----------
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
float myfloat = 0.001;
double mydouble = 0.0001;
printf("==== dB Printout ====\nFloat: % .5f (% .1f dB) -- Double: % .5f (% .1f
dB)\n", myfloat, log10f(myfloat)*10.0, mydouble, log10(mydouble)*10.0);
printf("==== B Printout ====\nFloat: % .5f (% .1f B) -- Double: % .5f (% .1f
B)\n", myfloat, log10f(myfloat), mydouble, log10(mydouble));
}
---------- SNIP -----------
Output produced:
==== dB Printout ====
Float: 0.00100 ( 10752580800.0 dB) -- Double: 0.00010 ( 125760.0 dB)
==== B Printout ====
Float: 0.00100
(-9073737388866367603040942298049721307647176680268405669064496879808260350778408368798593112776285209317055458675661852075962312342200835280061159040530765214192402488102355092477628744792158548183167207997440.0
B) -- Double: 0.00000 ( 2.1 B)
This seems completely wrong. Why does multiplying the result of log10() by 10.0
completely trash the value, for example?
=MB=
--
Summary: Float and double math produces unexpected results.
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at paypc dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-slackware-linux
GCC host triplet: i486-slackware-linux
GCC target triplet: i486-slackware-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15019
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/15019] Float and double math produces unexpected results.
2004-04-20 4:03 [Bug c/15019] New: Float and double math produces unexpected results gcc at paypc dot com
@ 2004-04-20 4:25 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-20 4:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-20 02:45 -------
Not a bug:
pr15019.c: In function `main':
pr15019.c:10: warning: implicit declaration of function `log10f'
pr15019.c:10: warning: implicit declaration of function `log10'
pr15019.c:12: warning: double format, different type arg (arg 3)
pr15019.c:12: warning: double format, different type arg (arg 5)
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15019
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-04-20 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-20 4:03 [Bug c/15019] New: Float and double math produces unexpected results gcc at paypc dot com
2004-04-20 4:25 ` [Bug c/15019] " pinskia at gcc dot gnu dot org
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).