1

When I convert a variable using the functions toNumber() or toString() I obtain this result: x.toNumber()

1e+27

But I want to see the entire number with all the figures. Because If I don´t convert the number, the big number format it´s something like this:

BigNumber { s: 1, e: 26, c: [ 9999999500000 ] }
0

Try this. I'm assuming you're fetching a response from a contract.

var theNumber;
myContract.getNumber()
.then(function(response) {
  theNumber = response;
  console.log(theNumber.toString(10));
});

You can lower the magnitude with fromWei(theNumber, 'unit'). Something like

var shift18;
...
  shift18 = fromWei(theNumber, 'ether'); // (18 decimals)
  console.log(shift18.toString(10));

Hope it helps.

| improve this answer | |
0

Try this:

var value = new BigNumber(resultis.args._amount);

//converting the bignumber from wei to ether, 18 decimal, replace trailing zero

var value = (web3.fromWei(value, "ether").toFixed(18)).replace(/^0+(\d)|(\d)0+$/gm, '$1$2');

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.