Most likely the reason is that 234999.0 cannot be perfectly represented in double-precision floating-point format, and instead it is represented as a vlue just slightly less than 234999.0 (e.g. 234998.999999999...) - thus, when you perform the cast, you simply chop off the decimal digits instead of rounding. Try int temp = int(newnumber+0.5) for traditional rounding.