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.
We have C = A * B, where all of them are BoundedInt. We represent the BoundedInt as:
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:
AdwithPbits.BdwithQbits.Ad * BdwithX = max(P, Q) * 2bitsAd * BowithY = max(P, S) * 2bitsBd * AowithZ = max(Q, R) * 2bitsAnd compile-time values:
AowithRbits.BowithSbits.Ao * Bo - CowithWbits.We should check if this new implementation is more performant than what we have now. This algorithm implementation can be seen here.