cowprotocol/ethcontract-rs

Implement division for `I256`

Closed this issue · 2 comments

Currently, the 256-bit signed integer type does not implement division (oops!). This issue captures the work for implementing division and division related operations:

  • Implement Div and Rem traits for division and remainder (modulo) calcuations.
  • Implement {overflowing,checked,wrapping,saturating}_{div,rem,div_rem} methods for all the different flavours of standard division and remainder calculations.
  • Implement {overflowing,checked,wrapping,saturating}_{div,rem,div_rem}_euclid for euclidean versions of the above calculations. Note that euclidian division and remainder have slightly different semantics than standard integer division when the divisor is negative.

@bh2smith Take a look if you're interested!

Sounds like a nice juicy task however I will require more clarification on the meaning of {overflowing,checked,wrapping,saturating}_{div,rem,div_rem} and your definition of the difference between euclidean and standard integer division when divisor is negative.