function toUnit(balance) {
	let decimals = global.chainDecimals;
	base = new BN(10).pow(new BN(decimals));
	dm = balance.divmod(base);
	modulus = dm.mod.abs().toString();
	if (!dm.mod.isZero()) {
		// make sure there are enough front zeros
		const additionalZeros = decimals - modulus.length;
		for (let i = 0; i < additionalZeros; i++) {
			modulus = '0' + modulus;
		}
		// remove all trailing zeros
		while (modulus.slice(-1) == "0") {
			modulus = modulus.slice(0, modulus.length - 1);
		}
	}
	let sign = "";
	if (dm.mod < 0) {
		sign = "-";
	}
	return sign + dm.div.toString() + "." + modulus + " " + global.chainToken
}
// Convert a big number balance to expected float with correct units.
Convert a big number balance to expected float with correct units.
Convert a big number balance to expected float with correct units .
function toUnit(balance) {
	let decimals = global.chainDecimals;
	base = new BN(10).pow(new BN(decimals));
	dm = balance.divmod(base);
	modulus = dm.mod.abs().toString();
	if (!dm.mod.isZero()) {
		const additionalZeros = decimals - modulus.length;
		for (let i = 0; i < additionalZeros; i++) {
			modulus = '0' + modulus;
		}
		while (modulus.slice(-1) == "0") {
			modulus = modulus.slice(0, modulus.length - 1);
		}
	}
	let sign = "";
	if (dm.mod < 0) {
		sign = "-";
	}
	return sign + dm.div.toString() + "." + modulus + " " + global.chainToken
}
function toUnit ( balance ) { let decimals = global . chainDecimals ; base = new BN ( 10 ) . pow ( new BN ( decimals ) ) ; dm = balance . divmod ( base ) ; modulus = dm . mod . abs ( ) . toString ( ) ; if ( ! dm . mod . isZero ( ) ) { const additionalZeros = decimals - modulus . length ; for ( let i = 0 ; i < additionalZeros ; i ++ ) { modulus = '0' + modulus ; } while ( modulus . slice ( - 1 ) == "0" ) { modulus = modulus . slice ( 0 , modulus . length - 1 ) ; } } let sign = "" ; if ( dm . mod < 0 ) { sign = "-" ; } return sign + dm . div . toString ( ) + "." + modulus + " " + global . chainToken }
Convert a big number balance to expected float with correct units.
Convert a big number balance to expected float with correct units .
// make sure there are enough front zeros // remove all trailing zeros