Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя shiny_shine

Автор shiny_shine, история, 6 месяцев назад, По-английски

As you know, in this reason, 64-bit C++ compilers are temporarily disabled.

In order to keep using __int128 (at least partially) in 32-bit compilers, I'm trying writing a template of the unsigned version of __int128.

On 2024/3/15, I completed writing the alpha version of it.

If you find bugs in my code, please leave a comment below. Thanks!

UPD:

2024/3/14: added (maybe) all operators that an __int128 has except for operator/ / fixed infinite-recursion bug in several operators

2024/3/15: added operator/ / fixed many bugs in almost all arithmetic operators / completed first (buggy) version of this handmade __int128

Here's it:

integer_128_impl.cpp
  • Проголосовать: нравится
  • +19
  • Проголосовать: не нравится

»
6 месяцев назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

This works similar to how people would hack higher precision real numbers into older system that does not provide support a long time ago. Pretty cool!

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The code is pretty neat.

Meanwhile, I found something similar to your implementation: the std::_Signed128 and std::_Unsigned128 in MSC++2019, which may be a firm reference for implementing signed __int128.

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by shiny_shine (previous revision, new revision, compare).

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Very nice code! There is also an alternative one adapted from abseil, with some modification. Unfortunately, it is tediously long.

Spoiler
»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
    ll min(ll x,ll y){
        return x<y?x:y;
    }

    ll max(ll x,ll y){
        return x>y?x:y;
    }

Seriously?

  • »
    »
    6 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    In fact it doesn't matter if you remove them

    but I think this impl has a better performance

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by shiny_shine (previous revision, new revision, compare).

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by shiny_shine (previous revision, new revision, compare).