Twos complement integers in JS are a bit of a sham. All numbers in JS are actually represented as floating points. I remember a while ago I had this fact bite me in the ass while trying to work with large integers. Here’s more info if anyone’s interested.
http://2ality.com/2012/04/number-encoding.html
Blame me for being blunt but it’s a bit stupid. The spec of the language has had that for ages: https://www.ecma-international.org/ecma-262/5.1/#sec-11.4.8
Maybe it’s just me, but I enjoy reading the spec of a language I’m learning, and if there’s no spec it’s usually a red flag.
i remember when the original article was posted and seeing it and just laughing and feeling sorry for the author. Nice to see he has corrected himself.
Twos complement integers in JS are a bit of a sham. All numbers in JS are actually represented as floating points. I remember a while ago I had this fact bite me in the ass while trying to work with large integers. Here’s more info if anyone’s interested. http://2ality.com/2012/04/number-encoding.html
Blame me for being blunt but it’s a bit stupid. The spec of the language has had that for ages: https://www.ecma-international.org/ecma-262/5.1/#sec-11.4.8 Maybe it’s just me, but I enjoy reading the spec of a language I’m learning, and if there’s no spec it’s usually a red flag.
i remember when the original article was posted and seeing it and just laughing and feeling sorry for the author. Nice to see he has corrected himself.