4 ms·
> You have about a .1% chance of generating an ID that gets truncated in JavaScript I don't follow. 1-(Number.MAX_SAFE_INTEGER / 2*63) ~ 99.9%, so don't you ha
by Recursing 3y ago
> You have about a .1% chance of generating an ID that gets truncated in JavaScript
I don't follow. 1-(Number.MAX_SAFE_INTEGER / 2*63) ~ 99.9%, so don't you have a >99% chance of generating an ID that gets truncated in js?
- js2 3y agoIEEE 754 can represent integers larger than MAX_SAFE_INTEGER, just not all of them: https://en.wikipedia.org/wiki/Double-precision_floating-point_format#Precision_limitations_on_integer_values https://en.wikipedia.org/wiki/Double-precision_floating-poin... That's still going to be a greater than 0.1% chance of hitting a non-representable value though.
- hinkley 3y agoIt’s been a long long time. I may be remembering the ratio wrong, or we might have been clipping the range a bit.
- Dylan16807 3y ago> or we might have been clipping the range a bit Well it's a pretty abrupt change. 53 bits work fine, at 54 bits a quarter of numbers get truncated, at 55 it's half.