• NeatNit
    link
    fedilink
    arrow-up
    7
    arrow-down
    15
    ·
    1 month ago

    AFAIK that should give you +infinity, not NaN

    • Abnorc@lemm.ee
      link
      fedilink
      arrow-up
      30
      ·
      1 month ago

      Almost. 1/x approaches infinity from the positive direction, but it approaches negative infinity from the negative direction. Since they approach different values, you can’t even say the limit of 1/x is infinity. It’s just undefined.

      • affiliate@lemmy.world
        link
        fedilink
        arrow-up
        12
        ·
        1 month ago

        it is possible to rigorously say that 1/0 = ∞. this is commonly occurs in complex analysis when you look at things as being defined on the Riemann sphere instead of the complex plane. thinking of things as taking place on a sphere also helps to avoid the “positive”/“negative” problem: as |x| shrinks, 1 / |x| increases, so you eventually reach the top of the sphere, which is the point at infinity.

      • NeatNit
        link
        fedilink
        arrow-up
        6
        ·
        1 month ago

        https://en.wikipedia.org/wiki/Division_by_zero#Floating-point_arithmetic

        In IEEE arithmetic, division of 0/0 or ∞/∞ results in NaN, but otherwise division always produces a well-defined result. Dividing any non-zero number by positive zero (+0) results in an infinity of the same sign as the dividend. Dividing any non-zero number by negative zero (−0) results in an infinity of the opposite sign as the dividend. This definition preserves the sign of the result in case of arithmetic underflow.

      • NeatNit
        link
        fedilink
        arrow-up
        3
        ·
        1 month ago

        https://en.wikipedia.org/wiki/Division_by_zero#Floating-point_arithmetic

        In IEEE arithmetic, division of 0/0 or ∞/∞ results in NaN, but otherwise division always produces a well-defined result. Dividing any non-zero number by positive zero (+0) results in an infinity of the same sign as the dividend. Dividing any non-zero number by negative zero (−0) results in an infinity of the opposite sign as the dividend. This definition preserves the sign of the result in case of arithmetic underflow.