BUG: static_cast<double> was done too late leading to possible wrong computation of the normalization