Also, keep in mind that variables can be typecasted. For example:
int x = 5;
float sum = (float)(x) + 2.25;
I think I did that right, anyways.
cscgal
The Queen of DaniWeb
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
Hello guys,
is there a way to declare global variables as float and then convert them to int to be used in a function? i.e.
float num1, num2, result;
float Mod(){
num1%num2=result; //Wrong, (%) requires <strong>int</strong> type)
}
The fmod function returns the remainder of floating point division.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
something like this should work:
myfloat <- float
myint <- int
myint = 0;
while(myfloat >= 1){
myint++;
myfloat--;
}
Something like that would do the trick... I might have my reasoning a little of but I'm sure that it would work.
Natso
Junior Poster in Training
51 posts since May 2004
Reputation Points: 10
Solved Threads: 1