Skip to content

Commit

Permalink
style(SignedInt): format operation functions' bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
icanvardar committed Jul 28, 2024
1 parent 7efe616 commit 08c09c9
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/types/SignedInt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ function divSignedInt(SignedInt left, SignedInt right) pure returns (SignedInt r
revert(0x9c, 0x04)
}

let leftNeg := slt(left, 0)
let rightNeg := slt(right, 0)
let sign := xor(leftNeg, rightNeg)
let l := slt(left, 0)
let r := slt(right, 0)
let sign := xor(l, r)

if leftNeg { left := sub(0, left) }
if rightNeg { right := sub(0, right) }
if l { left := sub(0, left) }
if r { right := sub(0, right) }

let absRes := div(left, right)
res := absRes
if sign { res := sub(0, absRes) }
res := div(left, right)

if sign { res := sub(0, res) }
}
}

Expand All @@ -63,13 +63,13 @@ function modSignedInt(SignedInt left, SignedInt right) pure returns (SignedInt r
revert(0x9c, 0x04)
}

let leftNeg := slt(left, 0)
if leftNeg { left := sub(0, left) }
let l := slt(left, 0)
if l { left := sub(0, left) }
if slt(right, 0) { right := sub(0, right) }

let absRes := mod(left, right)
res := absRes
if leftNeg { res := sub(0, absRes) }
res := mod(left, right)

if l { res := sub(0, res) }
}
}

Expand All @@ -81,12 +81,9 @@ function expSignedInt(SignedInt left, SignedInt right) pure returns (SignedInt r
revert(0x9c, 0x04)
}

let leftNeg := slt(left, 0)
let absLeft := left

res := exp(absLeft, right)
res := exp(left, right)

if leftNeg { res := sub(0, res) }
if slt(left, 0) { res := sub(0, res) }
}
}

Expand Down

0 comments on commit 08c09c9

Please sign in to comment.