• moseschrute@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 days ago

    I agree, storing in a consistent unit is the way. That doesn’t solve conversion/rounding issues, but it does simplify things.

    Though you can run into floating point errors when editing in one unit vs storing in another. For example, maybe the user entered 2 in unit A, then it’s converted to unit B and stored in the db. However, when it’s converted back to unit A, it’s 1.999999. Fortunately rounding fixes this. We say unit A and B get 2 decimals of precision, and 1.999999 becomes 2.00.