1139399025 is not a floating point number: the largest odd integer that
can be exactly represented as a float
is
224 − 1 = 16777215. Then, when var3
is
cast to float
, it gets rounded to the closest float, which
is 1139399040. This is quite a small error, especially considering
that, in this range, only multiples of 128 can be exactly
represented as floats.
Dividing 1139399040 by 10 gives 113939904, which happens to be a float.
The floating point division gives then the exact result, which is what
gets printed. Indeed, floating point operations do not always give
inexact results: sometimes they are exact. However, unless you know what
you are doing, exact results only happen by luck. In general, expect
each floating point operation to make a relative rounding error in the
range of 10−7.
A highly recommended read: What Every Programmer Should Know About
Floating-Point Arithmetic.
Edit: If you want to print the value of an integer divided by 10,
you can divide the number using Euclidean division. Print the
quotient, then the decimal point, then the remainder:
Serial.print(var3 / 10); // quotient
Serial.print('.');
Serial.println(var3 % 10); // remainder
As these are all integer operations, there is no rounding error
involved. Obviously this trick doesn't work for arbitrary divisors.