Difference in evaluation of expression when using long long int vs double in c++ [duplicate]

double is a floating point type. Floating point types have limited precision. They cannot represent all numbers - not even all rational numbers. Simply (on your system) 603828039791327040 is a number that cannot be represented by the double datatype. The closest value that is representable happens to be 64 away from the precise value.

You can (likely) get the expected result by using long double which (typically) can represent all values of long long - or you could avoid using floating point in the first place.