From a3e312d133f9df1942b96b39cd007c883cd0331f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Tue, 16 Oct 2018 17:21:08 -0300 Subject: [PATCH] Added Math.sol docstrings. (#1423) --- contracts/math/Math.sol | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/contracts/math/Math.sol b/contracts/math/Math.sol index d51a720c9..ffff83961 100644 --- a/contracts/math/Math.sol +++ b/contracts/math/Math.sol @@ -5,14 +5,25 @@ pragma solidity ^0.4.24; * @dev Assorted math operations */ library Math { + /** + * @dev Returns the largest of two numbers. + */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } + /** + * @dev Returns the smallest of two numbers. + */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } + /** + * @dev Calculates the average of two numbers. Since these are integers, + * averages of an even and odd number cannot be represented, and will be + * rounded down. + */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);