So first of all thanks everyone for the suggestions. Btw for the moment the "double to string -> string to double -> floor" solution seems to be the only one giving exactly the expected result. So i just needed to replace:
double floored = floor(sum);
with
double floored = floor(stod(dtos(sum)));
If anyone has a better solution please post it.