Closed JamesCarlyleClarke closed 1 month ago
For maxValue, I don't see much reason to make the mag be something other than 1, since at that point the magnitude is meaningless anyway. As for maxSafeValue, since the transition point for layers is at a magnitude of 9e15, I'd make the magnitude there (9e15 - 1) rather than MAX_SAFE_INTEGER (which is slightly larger than 9e15).
I'll consider these for the next update.
Ah, interesting, I hadn't known about the 9e15 in the code, got it. Surely, since the relevant code is 'While abs(mag) > EXP_LIMIT (9e15)' then for the absolute maximum, it could be 9e15 not 9e15-1? Or did I miss a >= somewhere?
Decimal.dMaxSafeValue = FC(1, Number.MAX_SAFE_INTEGER, 9e15);
For maxValue, are you saying it's meaningless in a metaphorical way (ie the number is so big that it's not worth worrying about the extra), or that it is meaningless because it is ignored in the code when the layer is that high, because the numbers are too big to calculate correctly and would overflow?
That's the >= you're looking for (it's in normalize).
As for maxValue, I guess it's a mix of both. Beyond 2^53 layers, the layer can no longer be incremented by 1, and since the mag's whole range is a single layer, the mag is effectively worthless.
Ah OK. Thanks for explaining, that's great! Still, for the absolute absolute maximum, if you simply had to have the highest valid number, does that mean it would be:
Decimal.dMaxValue = FC(1, Number.MAX_VALUE, Number.MAX_VALUE);
or
Decimal.dMaxValue = FC(1, Number.MAX_VALUE, 9e15-1);
or
Decimal.dMaxValue = FC(1, 2 ** 53, Number.MAX_VALUE);
or
Decimal.dMaxValue = FC(1, 2 ** 53, 9e15-1);
?
Decimal.dMaxValue would be FC(1, Number.MAX_VALUE, 9e15-1), and Decimal.dMaxSafeValue would be FC(1, 2 ** 53 - 1, 9e15-1).
Wonderful, that's extremely helpful, many thanks! (and while I'm chatting, thanks for the Eternal Notations library, just getting into that!)
These constants (Decimal.dLayerMax is the true maximum value, Decimal.dLayerSafeMax is the safe version) have been added in v2.1.0.
Many thanks, you're awesome!
The library would benefit from a max value constant. Is there any reason not to use Number.MAX_VALUE for the layer and mag?