Skip to content

Check new bounded_int_mul implementation #1478

@DiegoCivi

Description

@DiegoCivi

We have C = A * B, where all of them are BoundedInt. We represent the BoundedInt as:

  • X = Xo + Xd, where
    • X is a BoundedInt.
    • Xo is the lower bound of the BoundedInt range.
    • Xd is the offset.

So we have:
Cd = (Ad + Ao) * (Bd + Bo) - Co -> Cd = (Ad * Bd) + (Ad * Bo) + (Bd * Ao) + (Ao * Bo - Co)

We can separate it into run-time values:

  • Ad with P bits.
  • Bd with Q bits.
  • Ad * Bd with X = max(P, Q) * 2 bits
  • Ad * Bo with Y = max(P, S) * 2 bits
  • Bd * Ao with Z = max(Q, R) * 2 bits
    And compile-time values:
  • Ao with R bits.
  • Bo with S bits.
  • Ao * Bo - Co with W bits.

We should check if this new implementation is more performant than what we have now. This algorithm implementation can be seen here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions