Skip to content

Commit

Permalink
docs: update code examples in the README
Browse files Browse the repository at this point in the history
docs: add repo in package.json
feat: changelog
  • Loading branch information
PaulRBerg committed Apr 19, 2021
1 parent 2c93624 commit 0f2883a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.1] - 2021-04-19

### Changed

- Examples in the README.

## [1.0.0] - 2021-04-19

### Added

- First release of the library.

[1.0.1]: https://github.com/hifi-finance/prb-math/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/hifi-finance/prb-math/releases/tag/v1.0.0
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PRBMath [![Coverage Status](https://coveralls.io/repos/github/paulrberg/prb-math/badge.svg?branch=main)](https://coveralls.io/github/paulrberg/prb-math?branch=main) [![Styled with Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io) [![Commitizen Friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![License: WTFPL](https://img.shields.io/badge/License-WTFPL-yellow.svg)](https://spdx.org/licenses/WTFPL.html)
# PRBMath [![Coverage Status](https://coveralls.io/repos/github/hifi-finance/prb-math/badge.svg?branch=main)](https://coveralls.io/github/hifi-finance/prb-math?branch=main) [![Styled with Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io) [![Commitizen Friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![License: WTFPL](https://img.shields.io/badge/License-WTFPL-yellow.svg)](https://spdx.org/licenses/WTFPL.html)

**Smart contract library for advanced fixed-point math.** PRBMath operates with signed 59.18-decimal fixed-point and unsigned
60.18-decimal fixed-point numbers. The name stems from the fact that there can be up to 59/60 digits in the integer part and up to 18 decimals
Expand Down Expand Up @@ -59,13 +59,13 @@ contract SignedConsumer {
}
function signedExp(int256 x) external pure returns (int256 result) {
result = PRBMathCommon.exp(x);
result = PRBMathSD59x18.exp(x);
}
/// @notice Calculates x*y÷1e18 while handling possible intermediary overflow.
/// @dev Try this with x = type(int256).max and y = 5e17.
function signedMul(int256 x, int256 y) external pure returns (int256 result) {
result = PRBMathCommon.mulDiv(x, y);
result = PRBMathSD59x18.mulDiv(x, y);
}
/// @dev Note that "y" is a basic uint256 integer, not a fixed-point number.
Expand All @@ -91,20 +91,20 @@ import "prb-math/contracts/PRBMathUD60x18.sol";
contract UnsignedConsumer {
using PRBMathUD60x18 for uint256;
/// @dev Note that "x" must be greater than or equal to 1e18, lest the result would be negative, and negative numbers
/// are not supported by the unsigned 60.18-decimal fixed-point representation.
/// @dev Note that "x" must be greater than or equal to 1e18, lest the result would be negative, and negative
/// numbers are not supported by the unsigned 60.18-decimal fixed-point representation.
function unsignedLog2(uint256 x) external pure returns (uint256 result) {
result = x.log2();
}
function unsignedExp(uint256 x) external pure returns (uint256 result) {
result = PRBMathCommon.exp(x);
result = PRBMathUD60x18.exp(x);
}
/// @notice Calculates x*y÷1e18 while handling possible intermediary overflow.
/// @dev Try this with x = type(uint256).max and y = 5e17.
function unsignedMul(uint256 x, uint256 y) external pure returns (uint256 result) {
result = PRBMathCommon.mul(x, y);
result = PRBMathUD60x18.mul(x, y);
}
/// @dev Note that "y" is a basic uint256 integer, not a fixed-point number.
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "prb-math",
"description": "Smart contract library for advanced fixed-point math",
"version": "1.0.0",
"version": "1.0.1",
"author": {
"name": "Paul Razvan Berg",
"url": "https://paulrberg.com"
},
"bugs": {
"url": "https://github.com/hifi-finance/prb-math/issues"
},
"devDependencies": {
"@commitlint/cli": "^9.1.2",
"@commitlint/config-conventional": "^9.1.2",
Expand Down Expand Up @@ -61,6 +64,7 @@
"smart-contracts",
"solidity"
],
"homepage": "https://github.com/hifi-finance/prb-math#readme",
"importSort": {
".js, .jsx": {
"parser": "babylon",
Expand All @@ -75,6 +79,10 @@
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/hifi-finance/prb-math"
},
"scripts": {
"clean": "hardhat clean",
"commit": "git-cz",
Expand Down

0 comments on commit 0f2883a

Please sign in to comment.