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: |

Perpetrators of these scams will create a public group on Telegram to promote these investment packages that are usually accompanied by fake testimonies and sometimes advertised as being Shariah-compliant. Interested investors will be asked to directly message the representatives to begin investing in the various investment packages offered. Elsewhere, version 8.6 of Telegram integrates the in-app camera option into the gallery, while a new navigation bar gives quick access to photos, files, location sharing, and more. Some privacy experts say Telegram is not secure enough At the start of 2018, the company attempted to launch an Initial Coin Offering (ICO) which would enable it to enable payments (and earn the cash that comes from doing so). The initial signals were promising, especially given Telegram’s user base is already fairly crypto-savvy. It raised an initial tranche of cash – worth more than a billion dollars – to help develop the coin before opening sales to the public. Unfortunately, third-party sales of coins bought in those initial fundraising rounds raised the ire of the SEC, which brought the hammer down on the whole operation. In 2020, officials ordered Telegram to pay a fine of $18.5 million and hand back much of the cash that it had raised. 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.
from pl


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