It looks like your prehistoric compiler has 16-bit int
types. 149712 is too large to fit in 16 bits, so the calculation overflows and gives an incorrect value. You should:
- use
long
orint32_t
if you need a type that's guaranteed to be large enough to represent numbers up to a couple of billion; or perhapsfloat
ordouble
since you're doing floating-point arithmetic; - use a modern compiler. There have been two major updates to the language and standard library over the lifetime of that compiler, and the language you are writing is barely recognisable as C++.