From: colin AT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters) Subject: RE: cygwin and pow() 9 Apr 1998 03:41:50 -0700 Message-ID: <005701bd6297$529dd0e0$fa173185.cygnus.gnu-win32@gbird0.fu.is.saga-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit To: "Axel Riese" Cc: "GNU-Win32" Axel Riese wrote: >Could someone please help me with the following problem. I want to compute >0.5 ^ 0.75, which should give something close to 0.5946... > >/*********************************************************************/ >/* test.c */ >/*********************************************************************/ > >int main() >{ > double result; > > result = pow(0.5, 0.75); > printf("The result is: %f\n", result); > > return 0; >} > >/*********************************************************************/ > > >With Cygnus B19.1, I obtain the following: > >> test >The result is: 16416.000000 > > >Mingw32 gives: > >> test >The result is: 32.000000 > > >Am I doing something wrong ??????????????????? Try adding #include to the top of your source file to properly prototype pow. Also, try compiling with -Wall to get all the warnings (though I really think the warning about implicit declarations should be on by default... didn't it used to be?). Compiling my version of your test.c with -Wall gives the following: C:\tmp\scratch>gcc -Wall -o test.exe test.c test.c: In function `main': test.c:7: warning: implicit declaration of function `pow' test.c:8: warning: implicit declaration of function `printf' Problem: implicit declaration of the function pow causes gcc to assume it returns an int and insert code to convert the int to a double before assigning it to result, giving you a wrong answer. The output of the program compiled (with Mingw32 EGCS 1.0.2) with #include at the top is C:\tmp\scratch>test The result is: 0.594604 -- Colin Peters - colin at fu.is.saga-u.ac.jp -- Saga Univ. Dept. of Information Science -- http://www.geocities.com/Tokyo/Towers/6162/index.html -- http://www.fu.is.saga-u.ac.jp/~colin/index.html - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".