kevin.cianfarini
01/15/2025, 7:16 PMDuration. Based on this comment in the KEEP, it seems that the initial desire to model a duration as a single Double wasn’t sufficient because of precision issues, and that’s why duration now sacrifices a bit for either nano or millisecond representation.
> While storing a duration value as a Double number provides accuracy enough for practical purposes for both very short and very long durations, it may still feel unfortunate that adding or subtracting one nanosecond to/from a duration d slightly more than a hundred days resulted in rounding so that the result was equal to the same d.
If you were to reflect on this decision, would you make it again? Specifically, would you design Duration as a value class again? Or would it be better to design Duration like Java with two values — a Long number of seconds and an Int number of nanoseconds?
I’m asking because I am the author of alchemist which is heavily inspired by Duration. I’m working through some precision issues in my library and I’m wondering if the value proposition of a value class here is worth it to sacrifice an order of magnitude’s worth of precision like Duration does with nanos and millis.