Skip to content

Commit

Permalink
update documentation in "Fractions" library
Browse files Browse the repository at this point in the history
  • Loading branch information
vgorin committed May 5, 2019
1 parent aa95c1d commit d253640
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/Fractions.sol
@@ -1,5 +1,8 @@
pragma solidity 0.4.23;

/**
* @dev Deprecated. Use Fractions16/Fractions32 instead
*/
library Fractions {
/// @dev 32-bit structure representing proper fraction
struct Fraction {
Expand Down
6 changes: 6 additions & 0 deletions contracts/Fractions16.sol
@@ -1,11 +1,15 @@
pragma solidity 0.4.23;

/**
* @title Fractions 16-bit Library
*
* @notice Library for working with fractions.
* @notice A fraction is represented by two numbers - nominator and denominator.
* @dev A fraction is represented as uint16,
* higher 8 bits representing nominator
* and lower 8 bits representing denominator
*
* @author Basil Gorin
*/
library Fractions16 {
/**
Expand Down Expand Up @@ -96,6 +100,7 @@ library Fractions16 {
* @return nominator
*/
function getNominator(uint16 f) internal pure returns(uint8) {
// return high 8 bits
return uint8(f >> 8);
}

Expand All @@ -105,6 +110,7 @@ library Fractions16 {
* @return denominator
*/
function getDenominator(uint16 f) internal pure returns(uint8) {
// return low 8 bits
return uint8(f);
}

Expand Down

0 comments on commit d253640

Please sign in to comment.