Skip to content

Incorrect calculation of TotalPages in ApiArrayResult #4

Description

@skuill

Description:

The TotalPages property currently uses Math.Floor to calculate the number of pages, which results in incorrect values when the total number of items is not perfectly divisible by ItemsPerPage.

Problem:

In the current implementation:

return (int)Math.Floor((double)Total / ItemsPerPage);

This will cause the result to round down, omitting the additional page required for the remaining items.

Example:

If Total = 275 and ItemsPerPage = 20:

  • Expected TotalPages = 14 (13 full pages + 1 partial)
  • Actual TotalPages = 13 (incorrect)

Proposed Fix:

Replace Math.Floor with Math.Ceiling to ensure partial pages are counted correctly:

This will correctly return 14 pages for the example above.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions