1

Tried searching online why it does this. I tried changing the redix of the parseInt method but it doesn't seem to change anything as well.

var sum = [6, 1, 4, 5, 3, 9, 0, 1, 9, 5, 1, 8, 6, 7, 0, 5, 5, 4, 3]

// digits.length returns 19
var wholeNumber = sum.join("")
var makeNum = parseInt(wholeNumber)
console.log(wholeNumber) // returns string: 6145390195186705543
console.log(makeNum); // returns int: 6145390195186705000

Can anyone explain why makeNum does not return me the integer of wholeNumber but rather replaces the last 3 digits at the back with zeroes. I t

ROOT
  • 11,363
  • 5
  • 30
  • 45
  • 1
    since that number is bigger than `Number.MAX_SAFE_INTEGER`, you could use `BigInt(wholeNumber)` – Jaromanda X May 16 '20 at 07:15
  • makeNum returns an array list that number is bigger than an int u need to rethink what ur doing u if u want the sum of the values or concatenate them – mohamed lahsoumi May 16 '20 at 07:18

1 Answers1

1

That number is higher than the limit of an int. The max number you can use is 9007199254740991 6145390195186705543 is way larger.

Joel Hager
  • 2,990
  • 3
  • 15
  • 44