# Janet numbers are "doubles" representing each int up to 2^53 (9007199254740992)
# Above this, they can't, so these both eval to the same thing!
(math/exp2 53)
(+ 1 (math/exp2 53))
# After 2^53, doubles only represent even numbers
# Janet prints numbers above 2^53 in exponent form, hiding the end
(+ 2 (math/exp2 53)) # 9.00719925474099e+15
# But the odd numbers round interestingly!
# 2^53 + 2, 2^53 + 4 etc. are slots. We choose which to round e.g. 2^53 + 3 into.
# In school, we round .5 up, doubles above 2^53 round .5 to the neighbor divisible by 4!
(def p53 (math/exp2 53))
(= (+ p53 1) p53) # true
(= (+ p53 2) p53) # false
(= (+ p53 1) (+ p53 2)) # false
(= (+ p53 3) (+ p53 2)) # false
(= (+ p53 3) (+ p53 4)) # true
(= (+ p53 5) (+ p53 4)) # true
(= (+ p53 5) (+ p53 6)) # false
(= (+ p53 7) (+ p53 8)) # true
(= (+ p53 9) (+ p53 8)) # true
# After 2^54, it's the neighbor divisible by 8.
# After 2^55, it's the neighbor divisible by 16!
# It continues this way until 2^1024, which overflows to infinity
(= math/inf (math/exp2 1024)) # true