xc16 handles both double and float as 32-bit data types by default. You need to give the compilation option -fno-short-double
to use 64-bit doubles.
You may also be able to just use long double
as a data type, but I can't compile at the moment to verify that.
(As a test, 5,471,873,794,048 is also exactly the result you get compiling your sample code on x86 using float
instead of double
)