I suppose I should know this but I want to make a floating point variable into a plain integer variable. How though? I imagined something like averageTemp=inTemp where averageTemp is a floating point value but looking at the result it doesn't do the job!
Do you want rounding or simple truncation?
you can simply cast
float x = 4.3;
int y = (int) x;
or
long y = (long) x;
Simple truncation - I want to lose the decimal fraction.
Thank you mistergreen.
you can simply cast
You can perform an EXPLICIT cast that way. Or, you can simply assign the float value to an int variable and let the compiler perform an implicit cast.
float pi = 3.14159;
int three = pi;
Unless there is some reason to perform an explicit cast, don't.