Bug 111220 - exp function from math lib returns wrong values
Summary: exp function from math lib returns wrong values
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 9
Hardware: i686
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-11-30 12:29 UTC by Edward Pilipczuk
Modified: 2016-11-24 15:07 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2003-11-30 13:30:37 UTC
Embargoed:


Attachments (Terms of Use)

Description Edward Pilipczuk 2003-11-30 12:29:31 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1)
Gecko/20030225

Description of problem:
as in summary -> small example test:
----
#include <stdio.h>
main(){
  int i;
  for(i=0;i<10;i++) 
    printf( "exp(%f)=%e ?\n", 1.0*i, exp( 1.0*i ) );
}
----
compiled with command 'gcc -O2 -lm -otest test.c'
produces for example such results...
----
exp(0.000000)=2.057234e+10 ?
exp(1.000000)=2.057234e+10 ?
exp(2.000000)=2.057234e+10 ?
exp(3.000000)=2.057234e+10 ?
exp(4.000000)=2.057234e+10 ?
exp(5.000000)=2.057234e+10 ?
exp(6.000000)=2.057234e+10 ?
exp(7.000000)=2.057234e+10 ?
exp(8.000000)=2.057234e+10 ?
exp(9.000000)=2.057234e+10 ?
----


Version-Release number of selected component (if applicable):
  glibc-2.3.2-27.9.7

How reproducible:
Always

Steps to Reproduce:  as in description

Actual Results:  as in description

Expected Results:  it is the lates glibc patch for RH9
I think new one is required that will have at least math revised...


Additional info:

Comment 1 Jakub Jelinek 2003-11-30 13:30:37 UTC
This is a bug in the example.  Functions without prototypes are assumed
to return int.  exp returns double, not int, so this really cannot
work correctly, especially on architectures which return floating point
values in different registers than integral ones.
If you add #include <math.h> to the example, it will work just fine.


Note You need to log in before you can comment on or make changes to this bug.