diff --git a/docs/unit.md b/docs/unit.md index dd03c89..7d3db82 100644 --- a/docs/unit.md +++ b/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.