klamath
11-13-2000, 10:37 PM
I guess it's time for me to admit my embarrassingly poor knowledge of C. Unfortunately, I need to use it for a few simple programming contest questions.
I want to convert a float into an int. C's normal type conversion seems to just chop off the decimal part of the float. I want to round properly (with 0.5 -> 1). How would one do this?
Also, I vaguely remember a way to switch the values on 2 variables without using a temp variable (using bit arithmetic). Can someone tell me how to do this?
------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the BBB (http://bbb.sourceforge.net)
I want to convert a float into an int. C's normal type conversion seems to just chop off the decimal part of the float. I want to round properly (with 0.5 -> 1). How would one do this?
Also, I vaguely remember a way to switch the values on 2 variables without using a temp variable (using bit arithmetic). Can someone tell me how to do this?
------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the BBB (http://bbb.sourceforge.net)