Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
adwn
on Dec 7, 2022
|
parent
|
context
|
favorite
| on:
Fast midpoint between two integers without overflo...
That doesn't work when both are odd. For example, for x=1 and y=3 this gives 1 instead of 2.
almostnormal
on Dec 7, 2022
[–]
1/2 + 3/2 + 1 = 0 + 1 + 1 = 2
rocqua
on Dec 7, 2022
|
parent
[–]
Your final +1 is not in the expression by OP. You can get it by taking the correction term (x & y & 1) as mentioned in another comment.
almostnormal
on Dec 7, 2022
|
root
|
parent
[–]
woops, misread the indent-depth of the posts as reply, not to the same parent.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: