What is the meaning of `c`, `e`, and `s` in bignumber.js?
Asked Answered
W

1

6

What are the meanings of the c, e, and s fields in the object produced by bignumber.js?

For example:

> new BigNumber('1234')
{ c: [1234], e: 3, s: 1 }
> new BigNumber('12345678901234567890')
{ c: [123456, 78901234567890], e: 19, s: 1 }
Walkup answered 3/5, 2018 at 21:7 Comment(9)
They are well-documented on bignumber.js's github page.Transect
I'm voting to close this question as off-topic because no research was done.Transect
Looks like you mixed up the outputs?Pasol
@SamAxe that's not actually a close reason.Lacy
Ah okay, now that I know the answer, it's easy to search for "coefficient" in the docs. Without knowing that, though, it's not especially straight forward to search for, and google came up with nothing (except someone else asking the same question somewhere else, without an answer).Walkup
@JohnDvorak: sure it is. You'll notice I was able to apply it to my close vote.Transect
@SamAxe I mean, it's not a valid close reason. That would be "duplicate", if that applies to this question.Lacy
@JohnDvorak: Today it appears to be a valid reason.Transect
i think this question is valid. first i found via google from github was mikemcl.github.io/bignumber.js but didn't answer the question. what it is more, there are more repos than github. thanks to this open question I could find the solution, so I find it useful and quite straightforward. It saved me time, and thus have my positive vote.Cark
S
7
  • c | coefficient | number[]| Array of base 1e14 numbers
  • e | exponent | number | Integer, -1000000000 to 1000000000 inclusive
  • s | sign | number | -1 or 1
Sucy answered 3/5, 2018 at 21:14 Comment(4)
Where did you find this?Pasol
@Pasol Properties (note: i never used the library myself)Pieter
Thanks, you should edit your answer to include that linkPasol
How do you go back from BigNumber { s: 1, e: 18, c: [ 83897, 65512388205578 ] } to a regular number?Sandarac

© 2022 - 2024 — McMap. All rights reserved.