Skip to content

Commit

Permalink
min/max/abs
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Apr 20, 2021
1 parent 33435e8 commit 7beb1c0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions stdlib/utils.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0

function min<T>(T a, T b) pure internal returns (T ret) {
ret = (a < b) ? a : b;
}

function max<T>(T a, T b) pure internal returns (T ret) {
ret = (a > b) ? a : b;
}

function abs<T: T.isSigned>(T a) pure internal returns (T ret) {
ret = (a < 0) ? -a : a;
}

0 comments on commit 7beb1c0

Please sign in to comment.