Batman
Batman

Reputation: 6353

parseInt and Number casting result in different number from string

I'm trying to get a number from a string but it's returning the wrong value

Number("580682945690490185")
580682945690490200

parseInt("580682945690490185")
580682945690490200

Upvotes: 1

Views: 43

Answers (1)

Juan Diego Lozano
Juan Diego Lozano

Reputation: 1009

That number is bigger than the maximum safe number as in IEEE 754 you can only safely represent numbers between -(2^53 - 1) and 2^53 - 1.

You should try with BigInt which has no limit

Upvotes: 2

Related Questions