Glad that I could help you with your decimal problem. Before concluding, we may want to revisit some of the feedback you receive in post #18.
First, your unit conversions:
I assume that voltage has units of volt (V), current has units of ampere (A), and that power_factor is dimensionless. In that case, the computed value of realPower will have units of watt.
However, the calculation of cumulative energy consumption (accumulateEnergy) in your code above does not seem to be correct. Assuming that the factor 3600000.0 has units of s/kh (seconds per thousand hours), then the resulting value of accumulateEnergy will have the following units:
W / (s/kh) = kWh/s (=Wh/ms)
Therefore, for finalEnergyValue to have units of kWh (kilowatt-hours), you would need to multiply accumulateEnergy by a time-interval measured in seconds. Alternatively, if you multiply accumulateEnergy by a time-interval measured in milliseconds, the final result will have units of Wh (watt-hours).
Second, as noted in post #18, you need to estimate energy consumption by computing a numerical integral. Therefore, in order for your results to be valid (at least in an approximate sense), you need to factor in the actual length of the time-interval (Energy_count) into your calculations. For example, you could do use a backward Euler algorithm for numerical integration, and do the following:
accumulateEnergy = Energy_count * realPower / 3.6E6; // Energy in watt-hour
or
accumulateEnergy = Energy_count * realPower / 3.6E9; // Energy in kilowatt-hour
The accuracy of your results will depend on how quickly the power consumption changes between the sampling intervals.