Skip to content

assert that offset is an integer #26

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ldanilek
Copy link
Contributor

@ldanilek ldanilek commented Mar 6, 2025

users in discord are reporting errors that look like

offset exceeded count by -3.9999999999990905

https://discord.com/channels/1019350475847499849/1347058269528526878/1347058269528526878

which could be from two root causes:

  1. btree nodes are somehow getting counts that are not integers. i checked the float64 spec (and asked chatgpt deep research) and I don't see how this could happen, since all we do is start with 0 or 1 and do addition or subtraction.
  2. the input offset is not a precise integer

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ldanilek ldanilek requested a review from sujayakar March 6, 2025 16:21
Comment on lines 378 to 380
if (args.offset !== Math.floor(args.offset)) {
throw new Error("offset must be an integer");
}

Choose a reason for hiding this comment

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

you can use Number.isInteger

@ldanilek ldanilek requested a review from sujayakar March 7, 2025 19:23
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