have a decimal float from a user input calculation, say 2.856 that I need to turn into the integer 2.
Note, this has to be done in the code itself and cannot simply be output with %.0f; I need it for future calculations.
Additional Note, I have used
float Var1;
int Var2;
Var1 = 2.856;
Var2 = (int)Var1;
And if this is the easiest way to do it, please explain how (int) works, because I have no idea.
EDIT: Okay, so I was a little unclear in my explination, Var 1 = 2.856 is already determined by the code. I don't actually type out any numbers here; so using that I need to turn Var1 into Var2. So I can't type in code
Var2=(int)2.856
because 2.856 changes all the time. Can I do
Var2=(int)Var1?
Or anything to that extent?