Warning: mkdir(): No space left on device in /var/www/group-telegram/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/misha_writes_code/--): Failed to open stream: No such file or directory in /var/www/group-telegram/post.php on line 50
Миша пишет код | Telegram Webview: misha_writes_code/195 -
Telegram Group & Telegram Channel
Наткнулся на видос, где рассказывают, какие неочевидные проблемы могут возникнуть при поиске среднего двух чисел:

https://www.youtube.com/watch?v=sBtAGxBh-XI

Удивительно, что доклад на такую, казалось бы, простую тему может длиться час. Но там действительно огромное поле для ошибок.

При написании алгоритма поиска среднего велик соблазн сделать просто return (a + b) / 2, однако такая реализация может переполниться и привести к неопределенному поведению.

Ровно из-за такой ошибки в Java 9 лет некорректно работал бинпоиск. Аналогичная проблема была и в имплементации JS от Mozilla.

Помимо переполнения есть еще другие сложности: integer promotion при работе с short, зависящий от имплементации знак у char. Ловушки в специализации шаблонов. А кроме целых типов ведь есть еще флоты и указатели, с которыми тоже приколов хватает.

Если лень смотреть, то есть документ с описанием имплементации std::midpoint, на основе которого и был сделан доклад (тут не все, но все равно есть, что почитать):
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0811r3.html

Также можно глянуть итоговую имплементацию std::midpoint:
https://github.com/llvm/llvm-project/blob/main/libcxx/include/__numeric/midpoint.h



group-telegram.com/misha_writes_code/195
Create:
Last Update:

Наткнулся на видос, где рассказывают, какие неочевидные проблемы могут возникнуть при поиске среднего двух чисел:

https://www.youtube.com/watch?v=sBtAGxBh-XI

Удивительно, что доклад на такую, казалось бы, простую тему может длиться час. Но там действительно огромное поле для ошибок.

При написании алгоритма поиска среднего велик соблазн сделать просто return (a + b) / 2, однако такая реализация может переполниться и привести к неопределенному поведению.

Ровно из-за такой ошибки в Java 9 лет некорректно работал бинпоиск. Аналогичная проблема была и в имплементации JS от Mozilla.

Помимо переполнения есть еще другие сложности: integer promotion при работе с short, зависящий от имплементации знак у char. Ловушки в специализации шаблонов. А кроме целых типов ведь есть еще флоты и указатели, с которыми тоже приколов хватает.

Если лень смотреть, то есть документ с описанием имплементации std::midpoint, на основе которого и был сделан доклад (тут не все, но все равно есть, что почитать):
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0811r3.html

Также можно глянуть итоговую имплементацию std::midpoint:
https://github.com/llvm/llvm-project/blob/main/libcxx/include/__numeric/midpoint.h

BY Миша пишет код




Share with your friend now:
group-telegram.com/misha_writes_code/195

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

Pavel Durov, Telegram's CEO, is known as "the Russian Mark Zuckerberg," for co-founding VKontakte, which is Russian for "in touch," a Facebook imitator that became the country's most popular social networking site. In this regard, Sebi collaborated with the Telecom Regulatory Authority of India (TRAI) to reduce the vulnerability of the securities market to manipulation through misuse of mass communication medium like bulk SMS. "We're seeing really dramatic moves, and it's all really tied to Ukraine right now, and in a secondary way, in terms of interest rates," Octavio Marenzi, CEO of Opimas, told Yahoo Finance Live on Thursday. "This war in Ukraine is going to give the Fed the ammunition, the cover that it needs, to not raise interest rates too quickly. And I think Jay Powell is a very tepid sort of inflation fighter and he's not going to do as much as he needs to do to get that under control. And this seems like an excuse to kick the can further down the road still and not do too much too soon." Given the pro-privacy stance of the platform, it’s taken as a given that it’ll be used for a number of reasons, not all of them good. And Telegram has been attached to a fair few scandals related to terrorism, sexual exploitation and crime. Back in 2015, Vox described Telegram as “ISIS’ app of choice,” saying that the platform’s real use is the ability to use channels to distribute material to large groups at once. Telegram has acted to remove public channels affiliated with terrorism, but Pavel Durov reiterated that he had no business snooping on private conversations. Such instructions could actually endanger people — citizens receive air strike warnings via smartphone alerts.
from id


Telegram Миша пишет код
FROM American