converting between variable types

Not as straightforward as I thought. I'm just making dummy data for my continuous graphic display. I'd like the data to be the sin of the modulo of the number of times the routine has been called, then scaled to the display by multiplying by 100 and adding 12. Not sure what rules I've broken here:

int getData_ch2(){    //this routine is where data for channel 2 is generated
                      //drawNumCount is the number of times draw routine has been called
  int Data_ch2 = int (100 * sin ((float drawNumCount) % (2 * 3.141598)) + 12);
  return Data_ch2;  
}
//            end of getData_ch2

error code:

graphdata_06.ino: In function 'int getData_ch2()':
graphdata_06:156: error: expected primary-expression before 'int'
graphdata_06:156: error: expected ',' or ';' before 'int'

modulo of the number of times draw has been called % 2 pi radians that is

sin ((float drawNumCount)

You can't declare a new variable in the middle of a function call.

What are you trying to do?

Why do you feel it necessary to explicitly cast the result to an int? Are you worried that somehow the implicit cast will do something different?

drawNumCount is an integer declared in loop and used by subroutines. I'd like it to stay an integer and just convert it to float while I do the quick math calculations.

btw - Wow thanks for the quick reply.

Also you can’t use the modulo operator on a float so the type casting to a float is not even worthwhile.

I think what you’re looking for is

 int Data_ch2 = int (100 * sin (fmod(drawNumCount, (2 * 3.141598))) + 12);

I'd like it to stay an integer and just convert it to float while I do the quick math calculations.

The conversion to float will happen implicitly because sin() expects a float argument. You don't need an explicit cast/conversion.

Thanks for all the help everyone

sin() automatically takes the modulus of its argument, mod 2*pi radians.