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

    You think timezones are annoying? Try handling metrics that use imperial and metric, need to be rounded to different precisions across a large system, and are sometimes recorded in a different unit than it’s viewed in. Slap some floating point error on there, and you got yourself a fun time.

    I spent all day working on bug where backend was categorizing 19.9999 as falling between <20, but frontend was rounding it to 20 and categorizing it as >=20.

    • iglou@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      2 days ago

      I would say your biggest issue here is needing precise decimal point computations and using imprecise data types. Any software that requires precision in the decimals needs to use types that are made for precise decimals. No floating point error.

    • applebusch@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      0
      ·
      3 days ago

      This is why, in any competent software dealing with physics in any way, it is always metric under the hood. Someone wants to see a quantity in some stupid freedom units? Fine sure convert it for them, but internally everything should be metric. Physics is hard enough, there’s no reason to make it worse with an inconsistent unit system with built in footguns somehow.

      • 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.