On Sunday, 22 May 2016 at 12:03:16 UTC, Guillaume Piolat wrote:
I don't know how this works, someone has to propose it, clean it up and respond to feedback I guess.

Glancing briefly at the source, it appears (from what I saw) it's heavily based on doubling the size of a lower type (2 64's to equal a 128, etc). This means to get the next level up you double again. So if I read it right for example, the opIncrease does this almost verbatim:

  opIncrease() { //aka ++
    low++;
    if (low == 0) //overflow detection
      high++;
  }

Going from native up one level is easy enough, but to do a 256 type it would do the same from a lower level. Meaning the int256 type does opIncrease on 2 int128 types, which break down to the native long type. Making a 256 or 512 silently creates all the lower ones until it can lower to a native type as the starting point.


More importantly is if they fully act as built-in types with their declarations, except (for maybe auto promotion of course, although that might work too). The only two operations that are going to be slow no matter how you slice it are multiply and divide. If you don't use multiply or divide, your code will be fast regardless how many levels it goes.

Reply via email to