美文网首页
【Python】inf & nan

【Python】inf & nan

作者: 盐果儿 | 来源:发表于2023-05-23 17:16 被阅读0次

    "inf" stands for "infinity," while "nan" stands for "not a number." These are special floating-point values that can occur in numerical computations.

    Infinity (inf): In floating-point arithmetic, "inf" represents positive infinity (+∞) or negative infinity (-∞). It occurs when a value exceeds the maximum finite value that can be represented by the floating-point format. For example, dividing a positive number by zero or performing other operations that result in overflow can lead to an infinite value.

    Not a Number (nan): "nan" represents an undefined or indeterminate value. It typically occurs as a result of invalid operations, such as dividing zero by zero or taking the square root of a negative number. "nan" indicates that the result of the operation is not meaningful or cannot be determined.

    相关文章

      网友评论

          本文标题:【Python】inf & nan

          本文链接:https://www.haomeiwen.com/subject/qcixedtx.html