C# - Converting a float to an int... and changing the int depending on the remainder

Posted by Django Reinhardt on Stack Overflow See other posts from Stack Overflow or by Django Reinhardt
Published on 2010-04-05T12:28:54Z Indexed on 2010/04/05 12:33 UTC
Read the original article Hit count: 212

Filed under:
|
|

Hi, this is probably the really newbie question (well, I'm pretty sure it is), but I have a float that's being returned and I need a quick and efficient way of turning it into an int.

Pretty simple, but I have an exception. If the remainder of the float is anything other than .0 then I want to increment the int.

Some quick examples:

Float = 98.0, Int = 98
Float = 98.1, Int = 99
Float = 6.6, Int = 7
etc.

Thanks for any help!

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET