Topic: Error in p0811r2
Author: atmtaatmta@gmail.com
Date: Mon, 25 Feb 2019 06:04:06 -0800 (PST)
Raw View
------=_Part_650_1103033933.1551103446432
Content-Type: multipart/alternative;
boundary="----=_Part_651_1863476536.1551103446432"
------=_Part_651_1863476536.1551103446432
Content-Type: text/plain; charset="UTF-8"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0811r2.html
> The standard alternative
> a+(b-a)/2
> works for unsigned integers (even if b<a).
This is wrong. It work only if "b >= a".
You can use "(a >> 1) + (b >> 1) + (a & b & 0x1)" if both number is signed
this was patended by Samsung, but patent expired, see
https://stackoverflow.com/a/3816473 https://patents.google.com/patent/US6007232
or "std::min(a,b)+(std::max(a,b)-std::min(a,b))/2"
https://rise4fun.com/Z3/tVfo checked using SMT solver
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2bd6a4cd-f60b-47c0-a440-8e1e0c0f9d85%40isocpp.org.
------=_Part_651_1863476536.1551103446432
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0=
811r2.html<br><br>> The standard alternative<br><br>> a+(b-a)/2<br><b=
r>> works for unsigned integers (even if b<a). <br><br>This is wrong.=
It work only if "b >=3D a".<br><br>You can use "(a >&=
gt; 1) + (b >> 1) + (a & b & 0x1)" if both number is sig=
ned<br>this was patended by Samsung, but patent expired, see https://stacko=
verflow.com/a/3816473=C2=A0https://patents.google.com/patent/US6007232<div>=
<br>or "std::min(a,b)+(std::max(a,b)-std::min(a,b))/2"<br><br>htt=
ps://rise4fun.com/Z3/tVfo checked using SMT solver</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2bd6a4cd-f60b-47c0-a440-8e1e0c0f9d85%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2bd6a4cd-f60b-47c0-a440-8e1e0c0f9d85=
%40isocpp.org</a>.<br />
------=_Part_651_1863476536.1551103446432--
------=_Part_650_1103033933.1551103446432--
.