DEV Community

Discussion on: How can you swap two variables without using a third?

Collapse
 
ptdecker profile image
P. Todd Decker

JavaScript, by nature, stores all numbers as double-precision IEEE 754 floating point numbers. The 52 bits of the fractional portion is used to store integers. This results in 'maximum safe integer' of 2^53 - 1. Further complicating things is that JavaScript's bitwise operators only deal with the lowest 32 bits of JavaScript's 54-bit integers. So the bitwise approach will not work on big integers in JavaScript.

Collapse
 
d4vecarter profile image
Dave Carter™

I guess BigInt new primitive proposal will do the trick :)