DSPRelated.com
Forums

float powf(a,a) wrong results

Started by marc...@hotmail.com March 24, 2006
Hi Mike Dunn,
thank you very much that you concerned about my problems!!!!
Here are the test-version from my programm:

COMPILER COMMANDS:
-g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug" -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700

LINKER COMMANDS:
-g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug" -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700
___________________________________________________________
APPLICATION (RAM)

void main ()
{
float y;
......
Initialization
......
float a=0;

while (a<)
{
*eingabe=a;
y=powf(a,a);
komp_aufruf(eingabe,rueckgabe); //"component-call"

printf("rueckgabeCOMP:%f %f\n",a,*rueckgabe); //"result from flash"
printf("rueckgabeMAIN:%f %f\n",a,y); //"result from application"

a=a+1;
}
free(rueckgabe);
free(eingabe);
return ;
}
__________________________________________________________

________________________________________________________
COMPONENT(FLASH)

#include
#include

float komp_onente(float *eingabe_k, float *rueckgabe_k)
{
float i;
i=*eingabe_k;
*rueckgabe_k=powf(i,i);
return 0;
}
_________________________________________________________
THE RESULT
rueckgabeCOMP 0.0 1.0
rueckgabeMAIN 0.0 1.0

rueckgabeCOMP 1.0 1.0
rueckgabeMAIN 1.0 1.0

rueckgabeCOMP 2.0 4.0
rueckgabeMAIN 2.0 4.0

rueckgabeCOMP 3.0 0.0
rueckgabeMAIN 3.0 27.0

rueckgabeCOMP 4.0 256.0
rueckgabeMAIN 4.0 256.0

rueckgabeCOMP 5.0 0.0
rueckgabeMAIN 5.0 3125.0

rueckgabeCOMP 6.0 0.0
rueckgabeMAIN 6.0 46656.0

rueckgabeCOMP 7.0 0.0
rueckgabeMAIN 7.0 823543.0

rueckgabeCOMP 8.0 16777216.0
rueckgabeMAIN 8.0 16777216.0

............

Do you know why????
only the values 0,1,2,4,8,16... -1,-2,-4,-8,-16..... deliver a correct result.

Thank you very much
marco
Hi Marco,

see below

m...@hotmail.com schrieb:
> Hi Mike Dunn,
> thank you very much that you concerned about my problems!!!!
> Here are the test-version from my programm:
>
> COMPILER COMMANDS:
> -g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug" -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700
>
> LINKER COMMANDS:
> -g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug" -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700
> ___________________________________________________________
> APPLICATION (RAM)
>
> void main ()
> {
> float y;
> ......
> Initialization
> ......
> float a=0;
>
> while (a<)
> {
> *eingabe=a;
> y=powf(a,a);
> komp_aufruf(eingabe,rueckgabe); //"component-call"

The declaration of 'komp_aufruf' would be interseting. Maybe there is a
float/int Problem somewhere. It would be interesting to a a variable
'rueckgabe2' whitch returns the value of 'eingabe'.

>
> printf("rueckgabeCOMP:%f %f\n",a,*rueckgabe); //"result from flash"

Just to be sure:
printf("rueckgabeCOMP:%f %f\n",*eingabe,*rueckgabe); //"result from flash"

> printf("rueckgabeMAIN:%f %f\n",a,y); //"result from application"
>
> a=a+1;
> }
> free(rueckgabe);
> free(eingabe);
> return ;
> }
> __________________________________________________________
>
> ________________________________________________________
> COMPONENT(FLASH)
>
> #include
> #include float komp_onente(float *eingabe_k, float *rueckgabe_k)
float komp_onente(float *eingabe_k, float *rueckgabe_k2)
> {
> float i;
> i=*eingabe_k;

*rueckgabe_k2=i;

> *rueckgabe_k=powf(i,i);
> return 0;
> }
> _________________________________________________________
> THE RESULT
> rueckgabeCOMP 0.0 1.0
> rueckgabeMAIN 0.0 1.0
>
> rueckgabeCOMP 1.0 1.0
> rueckgabeMAIN 1.0 1.0
>
> rueckgabeCOMP 2.0 4.0
> rueckgabeMAIN 2.0 4.0
>
> rueckgabeCOMP 3.0 0.0
> rueckgabeMAIN 3.0 27.0
>
> rueckgabeCOMP 4.0 256.0
> rueckgabeMAIN 4.0 256.0
>
> rueckgabeCOMP 5.0 0.0
> rueckgabeMAIN 5.0 3125.0
>
> rueckgabeCOMP 6.0 0.0
> rueckgabeMAIN 6.0 46656.0
>
> rueckgabeCOMP 7.0 0.0
> rueckgabeMAIN 7.0 823543.0
>
> rueckgabeCOMP 8.0 16777216.0
> rueckgabeMAIN 8.0 16777216.0
>
> ............
>
> Do you know why????
> only the values 0,1,2,4,8,16... -1,-2,-4,-8,-16..... deliver a correct result.
>
> Thank you very much
> marco
>
>
Can mike talk german too? :-)

--Bhooshan
On 3/24/06, Bernhard Gustl Bauer wrote:
>
> Hi Marco,
>
> see below
>
> m...@hotmail.com schrieb:
> > Hi Mike Dunn,
> > thank you very much that you concerned about my problems!!!!
> > Here are the test-version from my programm:
> >
> >
> >
> > COMPILER COMMANDS:
> > -g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug"
> -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700
> >
> > LINKER COMMANDS:
> > -g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug"
> -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700
> > ___________________________________________________________
> > APPLICATION (RAM)
> >
> > void main ()
> > {
> > float y;
> > ......
> > Initialization
> > ......
> > float a=0;
> >
> > while (a<)
> > {
> > *eingabe=a;
> > y=powf(a,a);
> > komp_aufruf(eingabe,rueckgabe); //"component-call"
>
> The declaration of 'komp_aufruf' would be interseting. Maybe there is a
> float/int Problem somewhere. It would be interesting to a a variable
> 'rueckgabe2' whitch returns the value of 'eingabe'.
>
> >
> > printf("rueckgabeCOMP:%f %f\n",a,*rueckgabe); //"result from flash"
>
> Just to be sure:
> printf("rueckgabeCOMP:%f %f\n",*eingabe,*rueckgabe); //"result from
> flash"
>
> > printf("rueckgabeMAIN:%f %f\n",a,y); //"result from application"
> >
> > a=a+1;
> > }
> > free(rueckgabe);
> > free(eingabe);
> > return ;
> > }
> > __________________________________________________________
> >
> > ________________________________________________________
> > COMPONENT(FLASH)
> >
> > #include
> > #include
> >
> > float komp_onente(float *eingabe_k, float *rueckgabe_k)
> float komp_onente(float *eingabe_k, float *rueckgabe_k2)
> > {
> > float i;
> > i=*eingabe_k;
>
> *rueckgabe_k2=i;
>
> > *rueckgabe_k=powf(i,i);
> > return 0;
> > }
> > _________________________________________________________
> >
> >
> > THE RESULT
> > rueckgabeCOMP 0.0 1.0
> > rueckgabeMAIN 0.0 1.0
> >
> > rueckgabeCOMP 1.0 1.0
> > rueckgabeMAIN 1.0 1.0
> >
> > rueckgabeCOMP 2.0 4.0
> > rueckgabeMAIN 2.0 4.0
> >
> > rueckgabeCOMP 3.0 0.0
> > rueckgabeMAIN 3.0 27.0
> >
> > rueckgabeCOMP 4.0 256.0
> > rueckgabeMAIN 4.0 256.0
> >
> > rueckgabeCOMP 5.0 0.0
> > rueckgabeMAIN 5.0 3125.0
> >
> > rueckgabeCOMP 6.0 0.0
> > rueckgabeMAIN 6.0 46656.0
> >
> > rueckgabeCOMP 7.0 0.0
> > rueckgabeMAIN 7.0 823543.0
> >
> > rueckgabeCOMP 8.0 16777216.0
> > rueckgabeMAIN 8.0 16777216.0
> >
> > ............
> >
> > Do you know why????
> > only the values 0,1,2,4,8,16... -1,-2,-4,-8,-16..... deliver a correct
> result.
> >
> > Thank you very much
> > marco
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>

--
-------------------------------
"I've missed more than 9000 shots in my career.
I've lost almost 300 games. 26 times I've been trusted to take the game
winning shot and missed.
I've failed over and over again in my life.
And that is why I succeed."
-- Michael Jordan
--------------------------------
Hi,

Do you have a prototype to 'komp_aufruf' in the module where you call
this function? If not, the 'C' compiler assumes the function's return
type to be 'int'.

If you use -pdse225 option when you compile your files, the compiler
will generate erros on functions that are declared implicitly.

Niro.

--- Bernhard Gustl Bauer wrote:

> Hi Marco,
>
> see below
>
> m...@hotmail.com schrieb:
> > Hi Mike Dunn,
> > thank you very much that you concerned about my problems!!!!
> > Here are the test-version from my programm:
> >
> >
> >
> > COMPILER COMMANDS:
> > -g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug"
> -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700
> >
> > LINKER COMMANDS:
> > -g -k -q -al -o2 -fr"C:\ti\myprojects\komperzeug\Debug"
> -i"C:\ti\c6000\cgtools\include" -d"_DEBUG" -ml3 -mv6700
> > ___________________________________________________________
> > APPLICATION (RAM)
> >
> > void main ()
> > {
> > float y;
> > ......
> > Initialization
> > ......
> > float a=0;
> >
> > while (a<)
> > {
> > *eingabe=a;
> > y=powf(a,a);
> > komp_aufruf(eingabe,rueckgabe); //"component-call"
>
> The declaration of 'komp_aufruf' would be interseting. Maybe there is
> a
> float/int Problem somewhere. It would be interesting to a a variable
> 'rueckgabe2' whitch returns the value of 'eingabe'.
>
> >
> > printf("rueckgabeCOMP:%f %f\n",a,*rueckgabe); //"result from
> flash"
>
> Just to be sure:
> printf("rueckgabeCOMP:%f %f\n",*eingabe,*rueckgabe); //"result from
> flash"
>
> > printf("rueckgabeMAIN:%f %f\n",a,y); //"result from
> application"
> >
> > a=a+1;
> > }
> > free(rueckgabe);
> > free(eingabe);
> > return ;
> > }
> > __________________________________________________________
> >
> > ________________________________________________________
> > COMPONENT(FLASH)
> >
> > #include
> > #include
> >
> > float komp_onente(float *eingabe_k, float *rueckgabe_k)
> float komp_onente(float *eingabe_k, float *rueckgabe_k2)
> > {
> > float i;
> > i=*eingabe_k;
>
> *rueckgabe_k2=i;
>
> > *rueckgabe_k=powf(i,i);
> > return 0;
> > }
> > _________________________________________________________
> >
> >
> > THE RESULT
> > rueckgabeCOMP 0.0 1.0
> > rueckgabeMAIN 0.0 1.0
> >
> > rueckgabeCOMP 1.0 1.0
> > rueckgabeMAIN 1.0 1.0
> >
> > rueckgabeCOMP 2.0 4.0
> > rueckgabeMAIN 2.0 4.0
> >
> > rueckgabeCOMP 3.0 0.0
> > rueckgabeMAIN 3.0 27.0
> >
> > rueckgabeCOMP 4.0 256.0
> > rueckgabeMAIN 4.0 256.0
> >
> > rueckgabeCOMP 5.0 0.0
> > rueckgabeMAIN 5.0 3125.0
> >
> > rueckgabeCOMP 6.0 0.0
> > rueckgabeMAIN 6.0 46656.0
> >
> > rueckgabeCOMP 7.0 0.0
> > rueckgabeMAIN 7.0 823543.0
> >
> > rueckgabeCOMP 8.0 16777216.0
> > rueckgabeMAIN 8.0 16777216.0
> >
> > ............
> >
> > Do you know why????
> > only the values 0,1,2,4,8,16... -1,-2,-4,-8,-16..... deliver a
> correct result.
> >
> > Thank you very much
> > marco
> >