Skip to content

Fix integer precision in CLI numeric filters - #213

Open
HocVoNgThai wants to merge 1 commit into
SethMMorton:mainfrom
HocVoNgThai:fix/cli-integer-filter-precision
Open

HocVoNgThai wants to merge 1 commit into
SethMMorton:mainfrom
HocVoNgThai:fix/cli-integer-filter-precision

Conversation

@HocVoNgThai

Copy link
Copy Markdown

CLI numeric filters convert integer bounds and extracted tokens to float, causing distinct large integers to compare equal.

For example, excluding 9007199254740992 also removes item9007199254740993. This change keeps the latter entry and accepts ranges between these adjacent integers.

Preserve integer precision in integer modes and add regression coverage for exclusion, filtering, and reverse filtering.

Comment thread natsort/__main__.py
args = parser.parse_args(arguments or None, namespace=TypedArgs())

if args.number_type in _FLOAT_MODES:
# Convert via strings so oversized integer literals still become infinity.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a lot of reading this over and over to realize that it was not just throwing away the benefit of using integers for large numbers. Expanding the comments to explain that we letting these become infinity so that it is apples-to-apples comparisons with float would be helpful.

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.

2 participants