• @[email protected]
      link
      fedilink
      210 months ago

      Float processing is at the hardware level. It needs a way to signal when an unrepresented value would be returned.

      • Ephera
        link
        fedilink
        210 months ago

        My thinking is that a call to the safe division method would check after the division, whether the result is a NaN. And if it is, then it returns an Error-value, which you can handle.

        Obviously, you could do the same with a NaN by just throwing an if-else after any division statement, but I would like to enforce it in the type system that this check is done.

        • @[email protected]
          link
          fedilink
          2
          edit-2
          10 months ago

          I feel like that’s adding overhead to every operation to catch the few operations that could result in a nan.

          But I guess you could provide alternative safe versions of float operations to account for this. Which may be what you meant thinking about it lol

          • Ephera
            link
            fedilink
            110 months ago

            I would want the safe version to be the default, but yeah, both should exist. 🙃