Skip to content

Allow for larger integer values to be printed correctly#82

Closed
eddelbuettel wants to merge 3 commits intomasterfrom
feature/large_int_printing
Closed

Allow for larger integer values to be printed correctly#82
eddelbuettel wants to merge 3 commits intomasterfrom
feature/large_int_printing

Conversation

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Nov 22, 2025

PR #81 notes that the print function used in verbose mode defaults to '%d' yet the templates may be instantiated with integers of larger capacity than the four-byte int aka int32_t we default to.

So this PR changes this to print as '%zu' with a corresponding cast to size_t.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses the issue where verbose printing mode uses incorrect format specifiers for potentially large integer values. The changes cast node counts and indices to size_t before printing, ensuring proper formatting of values larger than 32-bit integers.

Key Changes:

  • Updated three annoylib_showUpdate calls to cast integer values to size_t
  • Modified format specifiers from %d to %lud (though this is incorrect - should be %zu)
  • Updated ChangeLog to document the changes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
inst/include/annoylib.h Updates three verbose print statements to cast template parameter values to size_t with modified format specifiers
ChangeLog Documents the changes to support printing larger integer indices

Note: The format specifier %lud used in all three changes is incorrect. The correct format specifier for size_t is %zu, which is already used correctly elsewhere in this codebase (lines 1138, 1197, 1328).


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@eddelbuettel
Copy link
Owner Author

CLosed in favour of #81.

@eddelbuettel eddelbuettel deleted the feature/large_int_printing branch November 23, 2025 14:56
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