In Visual Studio, double
is IEEE754 double precison. That has 53 bits of binary precision, or around 15-16 decimal significant figures.
Probably your diagnostic code that is printing the values only prints to 7 digits of precision. Or your debugger view only shows 7 digits of precision.
In other words the problem is not in the underlying data type, but in the way you are viewing that data.
Update 1
Your comments indicate that you believe that calculations on double precision values are being carried out to single precision. By default that will not be the case. It could happen if you have change the floating point precision control with a call to _controlfp
. However, if your floating point control is set at the default value, then operations on double precision values will not be rounded to single precision.
Update 2
Your Excel calculations are performing a different calculation. The output from your C++ program matches the code. The first non-zero value output -1.09526
which matches the code. Because the code says that the value should be dailycompoundval[1]
. The corresponding value from your Excel code is -1.095231419
which therefore does not match the C++ code.
In other words the question is a red-herring. There's no rounding problems here. The issue is entirely down to discrepancies between the two different versions of your code.
Update 3
Your C++ code does not match the expression in the latest update. The code uses a multiplicative factor of 1000, but your expression uses a factor of 10000.