• Cyborganism@lemmy.ca
    link
    fedilink
    English
    arrow-up
    19
    arrow-down
    1
    ·
    1 年前

    LOL! Man I learned that in college and never used it ever again. I never came across any scenarios in my professional career as a software engineer where knowing this was useful at all outside of our labs/homework.

    Anyone got any example where this knowledge became useful?

    • magic_lobster_party@fedia.io
      link
      fedilink
      arrow-up
      44
      ·
      1 年前

      It’s useful to know that floats don’t have unlimited precision, and why adding a very large number with a very small number isn’t going to work well.

      • Cyborganism@lemmy.ca
        link
        fedilink
        English
        arrow-up
        2
        ·
        11 个月前

        Yeah but you don’t really have to think about how it works in the background ever time you deal with that. You just know.

        You learn how once and then you just remember not to do that and that’s it.

        • magic_lobster_party@fedia.io
          link
          fedilink
          arrow-up
          2
          ·
          11 个月前

          I agree we don’t generally need think about the technical details. It’s just good to be aware of the exponent and mantissa parts to better understand where the inaccuracies of floating point numbers come from.

    • zqwzzle@lemmy.ca
      link
      fedilink
      English
      arrow-up
      14
      arrow-down
      1
      ·
      1 年前

      If you’re doing any work with accounting, or writing test cases with floating point values.

          • Womble@lemmy.world
            link
            fedilink
            English
            arrow-up
            3
            ·
            edit-2
            1 年前

            Eh, if you use doubles and you add 0.000314 (just over 0.03 cents) to ten billion dollars you have an error of 1/10000 of a cent, and thats a deliberately perverse transaction. Its not ideal but its not the waiting disaster that using single precision is.

      • Cyborganism@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 个月前

        No. I don’t have to remember that.

        I just have to remember the limits and how you can break the system. You don’t have to think about the representation.

    • okwhateverdude@lemmy.world
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      1
      ·
      1 年前

      How long has this career been? What languages? And in what industries? Knowing how floats are represented at the bit level is important for all sorts of things including serialization and math (that isn’t accounting).

      • Cyborganism@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 个月前

        Since 2008.

        I’ve worked as a build engineer, application developer, web developer, product support, DevOps, etc.

        I only ever had to worry about the limits, but never how it works in the background.

    • socsa@piefed.social
      link
      fedilink
      English
      arrow-up
      4
      ·
      11 个月前

      Accumulation of floating point precision errors is so common, we have an entire page about why unit tests need to account for it.

    • scratchee@feddit.uk
      link
      fedilink
      English
      arrow-up
      4
      ·
      11 个月前

      In game dev it’s pretty common. Lots of stuff is built on floating point and balancing quality and performance, so we can’t just switch to double when things start getting janky as we can’t afford the cost, so instead we actually have to think and work out the limits of 32 bit floats.

      • Cyborganism@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 个月前

        So you have to remember how it’s represented in the system with how the bits are used? Or you just have to remember some general rules that “if you do that, it’ll fuck up.”

        • scratchee@feddit.uk
          link
          fedilink
          English
          arrow-up
          2
          ·
          11 个月前

          Well, rules like “all integers can be represented up to 2^24” and “10^-38 is where denormalisation happens” are helpful, but I often have to figure out why I got a dodgy value from first principles, floating point is too complicated to solve every problem with 3 general rules.

          I wrote a float from string function once which obviously requires the details (intentionally low quality and limited but faster variant since the standard version was way too slow).

    • Alex@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 个月前

      Writing floating point emulation code?

      I’d pretty much avoided learning about floating point until we decided to refactor the softfloat code in QEMU to support additional formats.

      • Cyborganism@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 个月前

        The very wide majority of IT professionals don’t work on emulation or even system kernels. Most of us are doing simple applications, or working on supporting these applications, or their deployment and maintenance.