Skip to content

The way to calculate the average in the BinarySearch may cause overflow. #9

Open
@aimof

Description

@aimof

In BinarySearch, there are a code may cause overflow.

int((maxIndex + minIndex) / 2)

If (maxIndex + minIndex) is greater than max int, there occurs overflow and return wrong number.
We should calcurate like below.

int(minIndex + (maxIndex-minIndex)/2)

I'll make a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions