The definition of pow( ) takes doubles for both arguments. Try it w= ith double arguments and double result. Might also have rounding issue= s with the answer, e.g. 14.9999999... being truncated to 24. John
=
......................................................................= .....

John P. Nolan
Math/Stat Department
227 Gray Hall
American University
4400 Massachusetts Avenue, NW
Washington, DC 20016-8050

jpnolan@american.edu
202.885.3140 voice
202.885.3155 fax
......................................................................= .....

"Michael = Chen" <vancouver.michael@gmail.com>

=
"Michael Chen" <vancouver.michael@= gmail.com>
Sent by: mingw-msys-bounces@lists.sourceforge.net

09/07/2007 03:56 PM  Please respond to MSYS Discussion List

= =
 To mingw-msys@lists.sourceforge.net cc Subject [Mingw-msys] pow(5,2)=3D24 ?????!!!!!

Hi, there,

I spent several hours and still get pow(5,2)=3D24 at the last line of the code, please help!

Environment:
Windows XP
gcc.exe (GCC) 3.4.2 (mingw-special)

compile command:
gcc -g -Wall -lm spclen.c

Thanks for your help!

Michael Chen

------------------------------------------------------
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main()
{

double s=3D0;
int Tl=3D0,Ti=3D0;

s=3D0;Tl=3D0;Ti=3D0;
s=3Dcombinationformula(5,2,intexy11,&Tl,&Ti);
printf("%f\t%d\t%d\n",s,Tl,Ti);

}

double combinationformula(int l, int  d, double (*f)(int, double *= ),
int *Tl,int *Ti)
{
int i,j;
int k1norm;
int sign;
int *I;
int *idx;
double s=3D0;
double cho=3D0.0;

*Ti=3D0;
idx =3D idxtree(l,d,Tl);

....

}

int *idxtree(int L, int D, int *T)
{
int i,j;
int s;//length
int tr;//total of a row

int *p;//point to the full tree
int *r;//point to the reduced tree
int *f;//point to the flags

*T=3D0;//total of multi index

s =3D (int)pow(L,D); // wrong here, when L=3D5 D=3D2, I got 24!!= !

...
}

-----------------------------------------------------------------------= --
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.=