Skip to content

Commit

Permalink
Avoid loss of precision when converting to double.
Browse files Browse the repository at this point in the history
For some reason I cannot really explain, multiplying a float-value with
an integer-value and then converting the result to double causes
rounding. The loss of precision results in the small difference in
sim_time when loading eagerly vs loading lazily
  • Loading branch information
BjarneHerland committed Nov 10, 2021
1 parent 6296766 commit 2e7cb07
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ecl/ecl_sum_tstep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void ecl_sum_tstep_set_time_info(ecl_sum_tstep_type *tstep,
time_t sim_start = ecl_smspec_get_start_time(smspec);

if (sim_time_index >= 0) {
float sim_time = tstep->data[sim_time_index];
double sim_time = tstep->data[sim_time_index];
double sim_seconds = sim_time * ecl_smspec_get_time_seconds(smspec);
ecl_sum_tstep_set_time_info_from_seconds(tstep, sim_start, sim_seconds);
} else if (date_day_index >= 0) {
Expand Down

0 comments on commit 2e7cb07

Please sign in to comment.