GP32 sinus function problem


mutzel

Still Fresh
Joined
Oct 1, 2003
Messages
8
hi..

i try to use the sinus function with gcc & devkitadv but the output is always bullshit.

here my code ..

Code:
  if(sin(90)==1) /*for degrees*/
  GpTextOut(NULL, &gpDraw[nflip], 0, 0, "Degrees", 0);
  if(sin(M_PI/2)==1) /*for radians*/
  GpTextOut(NULL, &gpDraw[nflip], 0, 0, "Radians", 0);
  if(sin(100)==1) /*for grads*/
  GpTextOut(NULL, &gpDraw[nflip], 0, 0, "Grads", 0);

.. but nothing would be shown ..

so how to use sin()?


it will also be useful to know how to output a float value as text using GpTextOut... i wasn't able to get atoi() working correct...


thx
 
You're probably missing the math lib from your makefile. Put -lm at the end of your list of libs if it doesn't seem to be there. And to convert a float to a string use sprintf(string,"%f",float)
 
First off, it's sine, not "sinus". I wanted to point out that distiniction to avoid you any embarrasment.

Besides using sprintf, I think you can also use ftoa, or itoa with the input cast to an int (if you don't care about the fraction).
 
sprintf(string,"%f",float) this code crashes the geepee emu .. only sprintf(string,"%d",int) works fine :(

libm.a is already linked .. without -lm i cannot compile ..
 
generalnmx posted on Oct 19 2003 at 07:57 PM said:
First off, it's sine, not "sinus". I wanted to point out that distiniction to avoid you any embarrasment.

Besides using sprintf, I think you can also use ftoa, or itoa with the input cast to an int (if you don't care about the fraction).
ups i am sorry ... i thought there is no need to translate the (german) word "sinus" into english .. i did't know the word sine yet :D


but there is still the sine-problem ..

i tested some values ...
sin(2.139)=1.172
sin(2.159)=-1.512

.. the return values seams not to be the same like any sine function
 
Last edited by a moderator:
Back
Top