Skip to content

Safe BN is used to work with large BN with decimals. We build this on top of bn.js to support decimal

License

Notifications You must be signed in to change notification settings

solocker-app/solocker-safe-bn.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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);

About

Safe BN is used to work with large BN with decimals. We build this on top of bn.js to support decimal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published