Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
tiffanyh
on Dec 7, 2022
|
parent
|
context
|
favorite
| on:
Fast midpoint between two integers without overflo...
Using the midpoint function is the most readable.
https://en.cppreference.com/w/cpp/numeric/midpoint
Though it's odd this allows overflow.
abainbridge
on Dec 7, 2022
[–]
std::midpoint also seems to yield less efficient code with g++12 targeting x86-64:
https://godbolt.org/z/j695ce98Y
Lockal
on Dec 9, 2022
|
parent
[–]
std::midpoint does different thing in terms of rounding, therefore comparison is not fair.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
https://en.cppreference.com/w/cpp/numeric/midpoint
Though it's odd this allows overflow.