Browse Source

add explanatory example for need of Unit

patch-2
Manuel Araoz 10 years ago
parent
commit
5664dac015
  1. 10
      docs/unit.md

10
docs/unit.md

@ -8,6 +8,16 @@ description: Utility to easily convert between bitcoin units.
Unit is a utility for handling and converting bitcoin units. We strongly recommend to always use satoshis to represent amount inside your application and only convert them to other units in the front-end.
To understand the need of using the `Unit` class when dealing with unit conversions, see this example:
```
> 81.99 * 100000 // wrong
8198999.999999999
> var bitcore = require('bitcore');
> var Unit = bitcore.Unit;
> Unit.fromMilis(81.99).toSatoshis() // correct
8199000
```
## Supported units
The supported units are BTC, mBTC, bits (micro BTCs, uBTC) and satoshis. The codes for each unit can be found as members of the Unit class.

Loading…
Cancel
Save