4 ms·
Smells like floating point. Python prompt: >>> int(float('348555896224571969')) 348555896224571968 It just exceeds the mantissa bits of doubles: >>> ma
by fulafel 1y ago
Smells like floating point. Python prompt:
>>> int(float('348555896224571969'))
348555896224571968
It just exceeds the mantissa bits of doubles:
>>> math.log2(34855589622457196)
54.952239550875795
JavaScript (in)famously stores all numbers as floating point resulting in silent errors also with user perceived integers, so this might be an indication that Claude Code number handling uses JS native numbers for this.
- ec109685 1y agoThey wrap bash with python.
- fulafel 1y agoI still suspect JS. It's much harder to shoot yourself in the foot with Python. Even if you use JSON: >>> json.loads('{"nr": 348555896224571969}') {'nr': 348555896224571969} >>> type(_['nr']) <class 'int'>
- porridgeraisin 1y agoTIL that in the python REPL `_` automatically has the previous expr's result. That's cool
- mrspuratic 1y agoIt seems like it, but it can't be only that. A float64 representation of an int in the range 2^58 to 2^59 should be rounded to multiples of 2^6, i.e. 348555896224571968 as you found (3.48555896224571968E17) (the final digit 9 in the math.log2() expression was lost, it's 2^58 not 2^54) The unexpected output (according to the bugreport) arises from javascript, it does NOT round like everything else for reasons I don't understand. It seems to prefer rounding to arbitrary multiples of 10 in my limited testing.