From 7beb1c0db95c51e3fc3a58b3e087c8a828487437 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 20 Apr 2021 22:17:08 +0100 Subject: [PATCH] min/max/abs --- stdlib/utils.sol | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 stdlib/utils.sol diff --git a/stdlib/utils.sol b/stdlib/utils.sol new file mode 100644 index 000000000000..b854f183e972 --- /dev/null +++ b/stdlib/utils.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 + +function min(T a, T b) pure internal returns (T ret) { + ret = (a < b) ? a : b; +} + +function max(T a, T b) pure internal returns (T ret) { + ret = (a > b) ? a : b; +} + +function abs(T a) pure internal returns (T ret) { + ret = (a < 0) ? -a : a; +}