Skip to content

Commit

Permalink
fix precision loss on consumed_energy.csv
Browse files Browse the repository at this point in the history
Fix precision loss in consumed_energy.csv
Formatting with C99 "%g" cuts by 2 the precision of doubles, which is used to store dates. 
Now "%lf" is used instead, which is the standard format for doubles.
  • Loading branch information
JRodez authored and mpoquet committed Jul 12, 2024
1 parent 90e8656 commit f225198
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,12 @@ long double EnergyConsumptionTracer::add_entry(double date, char event_type)

if (epower != -1)
{
nb_printed = snprintf(buf, buf_size, "%g,%Lg,%c,%Lg,%g\n",
nb_printed = snprintf(buf, buf_size, "%lf,%Lf,%c,%Lf,%lf\n",
date, energy, event_type, wattmin, static_cast<double>(epower));
}
else
{
nb_printed = snprintf(buf, buf_size, "%g,%Lg,%c,%Lg,NA\n",
nb_printed = snprintf(buf, buf_size, "%lf,%Lf,%c,%Lf,NA\n",
date, energy, event_type, wattmin);
}
xbt_assert(nb_printed < buf_size - 1,
Expand Down

0 comments on commit f225198

Please sign in to comment.