Re: [Mingw-msys] [mingw - MSYS] Bison for MSYS (was: bash empty for-loop)
- Date: Fri, 7 Sep 2007 15:37:38 -0500
- From: "Michael Chen" <vancouver.michael@xxxxxxxxx>
- Subject: Re: [Mingw-msys] pow(5,2)=24 ?????!!!!!
int s = (int) pow(l,d);
printf("%d\t%d\t%d\n",l,d,s);
And I tried several (l,d), results are:
2 2 4
3 2 9
4 2 16
5 2 24 <= this one is wrong
6 2 36
....
What shall I use then? my variable s, l, and d are integers!
Michael Chen
jpnolan@xxxxxxxxxxxx
On 9/7/07, John Nolan <jpnolan@xxxxxxxxxxxx> wrote:
Oops, I meant 24.9999... being rounded to 24. John
John Nolan < jpnolan@xxxxxxxxxxxx>
John Nolan <jpnolan@xxxxxxxxxxxx>
Sent by: mingw-msys-bounces@xxxxxxxxxxxxxxxxxxxxx09/07/2007 04:16 PM
Please respond to
MSYS Discussion List <mingw-msys@xxxxxxxxxxxxxxxxxxxxx>
To
MSYS Discussion List <mingw-msys@xxxxxxxxxxxxxxxxxxxxx>
cc
Subject
Re: [Mingw-msys] pow(5,2)=24 ?????!!!!!
![]()
The definition of pow( ) takes doubles for both arguments. Try it with double arguments and double result. Might also have rounding issues 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@xxxxxxxxxxxx
202.885.3140 voice
202.885.3155 fax
http://academic2.american.edu/~jpnolan
...........................................................................
"Michael Chen" < vancouver.michael@xxxxxxxxx>
"Michael Chen" <vancouver.michael@xxxxxxxxx>
Sent by: mingw-msys-bounces@xxxxxxxxxxxxxxxxxxxxx09/07/2007 03:56 PM
Please respond to
MSYS Discussion List <mingw-msys@xxxxxxxxxxxxxxxxxxxxx>
To![]()
mingw-msys@xxxxxxxxxxxxxxxxxxxxx cc![]()
Subject![]()
[Mingw-msys] pow(5,2)=24 ?????!!!!!
![]()
Hi, there,
I spent several hours and still get pow(5,2)=24 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=0;
int Tl=0,Ti=0;
s=0;Tl=0;Ti=0;
s=combinationformula(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=0;
double cho=0.0;
*Ti=0;
idx = 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=0;//total of multi index
s = (int)pow(L,D); // wrong here, when L=5 D=2, 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.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Mingw-msys mailing list
Mingw-msys@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/mingw-msys
-------------------------------------------------------------------------
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.
Download your FREE copy of Splunk now >> http://get.splunk.com/_______________________________________________
Mingw-msys mailing list
Mingw-msys@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/mingw-msys
-------------------------------------------------------------------------
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.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Mingw-msys mailing list
Mingw-msys@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/mingw-msys
------------------------------------------------------------------------- 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. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________ Mingw-msys mailing list Mingw-msys@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/mingw-msys
- Follow-Ups:
- Re: [Mingw-msys] [mingw - MSYS] Bison for MSYS (was: bash empty for-loop)
- From: Max T. Woodbury
- Re: [Mingw-msys] [mingw - MSYS] Bison for MSYS (was: bash empty for-loop)
- Prev by Date: Re: [Mingw-msys] [mingw - MSYS] bash empty for-loop
- Next by Date: Re: [Mingw-msys] [mingw - MSYS] bash empty for-loop
- Previous by thread: [Mingw-msys] [mingw - MSYS] RE: bash empty for-loop
- Next by thread: Re: [Mingw-msys] [mingw - MSYS] Bison for MSYS (was: bash empty for-loop)
- Index(es):
-------------------------------------------------------------------------