Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 617 Bytes

README.md

File metadata and controls

29 lines (19 loc) · 617 Bytes

@solocker/safe-bn

To install

bun install @solocker/safe-bn

Usage

By default safe-bn support 3 decimal places to increase add the optional decimal param

Perform BigNumber mathematical operations

const target = 3124.456;
const safeBnRepresentation = safeBN(target);
// reverse to unSafe after performing mathematical operations
const unSafeRepresentation = unSafe(safeRepresentation);

Convert to Number from hex or BN

/// This unwrap safeBN, note don't pass unSafe output, convert first to save before this
const backToTarget = unSafeToNumber(safeRepresentation);