Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #292 fix overflow for complex-3 packing #298

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

webisu
Copy link
Collaborator

@webisu webisu commented Nov 29, 2024

Fixes issue #292
Grib2 uses packed (positive) integers, and the wgrib2 routines limit the length of integers to 25 bits. This is not a limitation for floating point numbers because the IEEE float format is limits the size of the mantissa to 24 bits (single precision). For most meteorological you only need 12-16 bits of precision. However, for precipitation people like high precision and routinely set the precision to 24 bits. The problem occurs with complex packing 3 which stores the deltas of the deltas. With an uncommon pattern of precip, the size of the scaled integers can increase 4 fold (+2 bits) which causes the scaled integers to exceed the 25 bit limit. This fix (1) updates the web documentation and (2) updates complex_pk.c which will not reduce the requested precision if necessary. Test for the fix was added.

@webisu webisu linked an issue Nov 29, 2024 that may be closed by this pull request
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.

Complex fails for 24 bits per value
1 participant