Skip to content

Instantly share code, notes, and snippets.

@ttsugriy
Created July 22, 2023 22:11
Show Gist options
  • Save ttsugriy/59fddcb54f29de6fd829e27e564a2500 to your computer and use it in GitHub Desktop.
Save ttsugriy/59fddcb54f29de6fd829e27e564a2500 to your computer and use it in GitHub Desktop.
different midpoints in C++
int midpointb(int l, int r) {
return (l + r) >> 1;
}
int midpointw(int l, int r) {
return l + (r - l) / 2;
}
int midpoint(int l, int r) {
return static_cast<unsigned int>(l + r) >> 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment