This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-23
Channels
- # aws (4)
- # beginners (14)
- # boot (7)
- # cider (75)
- # clara (87)
- # cljsrn (6)
- # clojure (115)
- # clojure-berlin (2)
- # clojure-dusseldorf (2)
- # clojure-gamedev (8)
- # clojure-italy (15)
- # clojure-russia (9)
- # clojure-spec (46)
- # clojure-uk (195)
- # clojurescript (24)
- # css (44)
- # datascript (19)
- # datomic (18)
- # emacs (6)
- # fulcro (57)
- # hoplon (1)
- # jobs (3)
- # jobs-discuss (37)
- # jobs-rus (3)
- # luminus (6)
- # lumo (28)
- # off-topic (24)
- # onyx (11)
- # planck (8)
- # re-frame (31)
- # remote-jobs (12)
- # rum (10)
- # schema (4)
- # shadow-cljs (28)
- # specter (24)
- # sql (3)
- # tools-deps (34)
- # vim (43)
- # yada (10)
@ronb yes, internally there is "high bits" and "low bits", that doesn't change based on value
as far as I remember, at least v8 can detect 31-bit ints and it’s more efficient to store them https://www.html5rocks.com/en/tutorials/speed/v8/#toc-topic-numbers
just compared memory consumption of my double trick to goog.math.Long. Using a double in this way is much smaller on every browser: Firefox 4x, Chrome 5x, Safari 5x
@tonsky @thedavidmeister the 31 bit rule only applies to 32 bit machines. 64bit engines use NAN-boxing. I found a good description here: https://softwareengineering.stackexchange.com/questions/185406/what-is-the-purpose-of-nan-boxing
a more in-depth analysis: http://wingolog.org/archives/2011/05/18/value-representation-in-javascript-implementations
basically a double is stored in the pointer directly with one of the redundant NaN values active (JS only has a single NaN representation)
> V8 doesn't actually use 63-bit smi values on 64-bit machines, AFAIK. so just 31 bits for fast immediate integers :(
> if a numeric value is bigger than 31 bits, V8 will box the number, turning it into a double and creating a new object to put the number inside.
hmm strange, that would mean my measurements were incorrect somehow. thanks for the info