Skip to content

Conversation

@ryanvolz
Copy link
Member

@ryanvolz ryanvolz commented Sep 18, 2020

This does away with use of long doubles for calculations with the sample rate. In the C library, this was used in digital_rf_get_subdir_file to determine file names and sample bounds. The np.longdouble sample rate was similarly used in the Python library to get the list of files containing a given sample index range.

The reason for this change is that not all platforms support long doubles with at least a 64-bit mantissa. This caused at least one bug on the aarch64 platform which resulted in incorrect file bounds from digital_rf_get_subdir_file. By using integer math that is implemented uniformly on all platforms, any bugs in the calculation should be more noticeable.

This commit also adds two new functions to the C API: digital_rf_get_timestamp_floor and digital_rf_get_sample_ceil. These are now used to do the file sample bound calculations, and they are exposed so that users of the library can perform these calculations in a way that is consistent with what is done internally. These functions have also been exposed in the Python binding, and a test that verifies that the sample index round-trips through them is included in the Python testing suite.

Because of the added C functions, the library version has been bumped to 2.7, which means the next release of Digital RF will be 2.7.0.

@ryanvolz ryanvolz changed the title c, python: Use integer math to calculate file sample bounds. Use integer math only, dropping use of long double sample rate Sep 18, 2020
@ryanvolz ryanvolz force-pushed the integer_math_only branch 2 times, most recently from 3b3c113 to 16657f0 Compare February 12, 2021 23:03
@ryanvolz ryanvolz force-pushed the integer_math_only branch 3 times, most recently from 4151ba4 to 5b83fad Compare December 13, 2023 14:46
@ryanvolz ryanvolz force-pushed the integer_math_only branch 3 times, most recently from 3581eff to 502b5ec Compare June 14, 2024 22:34
@ryanvolz ryanvolz force-pushed the integer_math_only branch 5 times, most recently from 830b559 to b69eb11 Compare June 27, 2025 22:22
This does away with use of `np.longdouble`s for calculations with the
sample rate in the Python library, which was used to get the list of
files containing a given sample index range. See 90cdb49 for the commit
that does the same thing in the C library.

This commit also exposes two new functions to the C API:
`digital_rf_get_timestamp_floor` and `digital_rf_get_sample_ceil`. These
are now used to do the file sample bound calculations, and they are
exposed so that users of the library can perform these calculations in a
way that is consistent with what is done internally. These functions
have also been exposed in the Python binding, and a test that verifies
that the sample index round-trips through them is included in the Python
testing suite.

Because of the added C functions, the library version has been bumped to
2.7, which means the next release of Digital RF will be 2.7.0.
This reuses the logic from the equivalent C functions to write these
Python functions in a way that lets them handle array inputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant