satoshi-rpgcoin
v1.0.0
Published
Convert Satoshi <-> Rpgcoin
Downloads
2
Maintainers
Readme
satoshi-rpgcoin
npm module to convert between Satoshi and Rpgcoin with lightweight precision.
Install
npm install --save satoshi-rpgcoin
Usage
Node.js
var sb = require('satoshi-rpgcoin');
sb.toSatoshi(1);
//=>100000000
sb.toRpgcoin(100000000);
//=>1
Web
<script src="https://rawgit.com/RPGCoin/satoshi-rpgcoin/master/index.bundle.js"></script>
<script>
console.log('One Satoshi equals ' + sb.toRpgcoin(1) + ' Rpgcoin');
</script>
Or download it with npm install --save satoshi-rpgcoin
and reference it as:
<script src="node_modules/satoshi-rpgcoin/index.bundle.js"></script>
Error Handling
try {
sb.toSatoshi(false)); //Throws TypeError
} catch (err) {
console.log(err);
}
API
sb.toSatoshi(number || string)
sb.toRpgcoin(number || string)
FAQ
What is a Satoshi?
- Satoshi is to Rpgcoin as pennies are to the dollar. Except that there are 100,000,000 Satoshi in one Rpgcoin.
Why do I need a module when I can just divide or multiply by 100,000,000?
- See here - Floating point errors are a bitch. So
satoshi-rpgcoin
uses a bignum library to ensure accurate conversions!
- See here - Floating point errors are a bitch. So
Tests
npm test
License
MIT ©