|
Re: Converting floating point to integers
This SHOULD make no difference, but sometimes code is like that. Dont declare a new variable for it. Just do:
float f = 245.56;
printf("%d\n", (int)f);
I've never had a problem doing it that way *shrugs* ... hope it works.
EDIT: actually, i think if you wanted to do it you way, just cast it again inside the printf, like this:
float f = 245.56;
int i;
i = (int)f;
printf("%d\n", (int)i);
I vaguely remember something about printf that if you dont cast inside the function, it does some weird things. Hope one of those works!
Last edited by colt527 : 28-01-2005 at 22:42.
|