Skip to content

Commit 1798ea9

Browse files
committed
Don't truncate to picoseconds when deriving the sampling rate
1 parent 9f7e9ae commit 1798ea9

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

include/data_types.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,14 @@ struct TimeDomainRecord : public BaseRecord
241241
, range_min(ValueY(0.0))
242242
, range_mid(ValueY(0.0))
243243
{
244-
/* The time unit is specified in picoseconds at most. Given that we're
245-
using a 32-bit float, we truncate any information beyond that point. */
246-
int time_unit_ps = static_cast<int>(raw->header->time_unit * 1e12);
247-
double time_unit = static_cast<double>(time_unit_ps) * 1e-12;
248-
249-
sampling_period.value = static_cast<double>(raw->header->sampling_period) * time_unit;
244+
sampling_period.value = static_cast<double>(raw->header->sampling_period) * raw->header->time_unit;
250245
sampling_frequency.value = std::round(1.0 / sampling_period.value);
251246

252247
double record_start;
253248
if (convert_horizontal)
254249
{
255250
step = sampling_period.value;
256-
record_start = static_cast<double>(raw->header->record_start) * time_unit;
251+
record_start = static_cast<double>(raw->header->record_start) * raw->header->time_unit;
257252
}
258253
else
259254
{

0 commit comments

Comments
 (0)