I need the value of string. Also, what is the significance of s , e , c .

truffle(development)> x.then(function(result) { 
{ [String: '100000000000000000000'] s: 1, e: 20, c: [ 1000000 ] }

I am able to fetch result[4].s or result[4].e

Sorry if this is a simple question. I am very new to javascript environment.


This is BigNumber. See A note on big numbers in web3.js.

You can convert it to string using toString method:

> const n = new web3.BigNumber('1234567890');
> n.toString()
> n.toString(16)

Also it seems that your return value is somehow related to money (ether or some other tokens). In this case you may find useful functions like web3.fromWei and web3.toWei:

> const n = new web3.BigNumber('100000000000000000000');
> web3.fromWei(n, 'ether').toString();
  • sure, will check out but how to separate out String in a variable. For ex: if I want to fetch c --> I would do console.log(result[4].c) . Similarly how to retrieve the string value
    – sun
    Mar 5 '17 at 20:22
  • 1
    Actually those c, s and e are internals of BigNumber and may be subject to change in the future. You should not rely on them in your code. it is better to use bignumber's public API. Mar 5 '17 at 20:27

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.