Skip to content

Replace int(int_value / int_value) with floordiv#132

Open
sterliakov wants to merge 1 commit intoJAMdotTech:masterfrom
sterliakov:chore/st-floordiv
Open

Replace int(int_value / int_value) with floordiv#132
sterliakov wants to merge 1 commit intoJAMdotTech:masterfrom
sterliakov:chore/st-floordiv

Conversation

@sterliakov
Copy link

While it can not cause any loss of precision for numbers under 2**53, and all the affected cases do not deal with numbers larger than 0xffffff, this is still a code smell (and is not obviously correct - using int(value / 4) instead of value // 4 can cause loss of precision for e.g. value = 2**63 - 1, resulting in a number off by one. Using floordiv with Python integers (which do not have limited bitwidth) avoids such questions entirely.

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.

1 participant