Infinity Representation in IEEE 754

Learn how IEEE 754 represents positive and negative infinity. Understand the bit patterns, when infinity arises in computations, and arithmetic rules involving infinity.

Special Values

Decimal Value

Infinity

Float32 Hex

0x7F800000

Float64 Hex

0x7FF0000000000000

Detailed Explanation

IEEE 754 uses specific bit patterns to represent positive and negative infinity. These special values arise from operations that overflow or divide by zero, and they follow well-defined arithmetic rules.

Bit patterns for infinity:

Value Float32 Hex Float64 Hex Binary Pattern
+Infinity 0x7F800000 0x7FF0000000000000 sign=0, exponent=all 1s, mantissa=all 0s
-Infinity 0xFF800000 0xFFF0000000000000 sign=1, exponent=all 1s, mantissa=all 0s

The key identifier: all exponent bits are 1, and all mantissa bits are 0. If even one mantissa bit were set, the value would be NaN instead.

How infinity arises:

  • Division by zero: 1.0 / 0.0 = +Infinity, -1.0 / 0.0 = -Infinity
  • Overflow: when a result exceeds the largest representable finite value (3.40e+38 for float32, 1.80e+308 for float64)
  • Explicit assignment: Infinity, -Infinity, float('inf') in Python

Note that 0.0 / 0.0 produces NaN, not infinity.

Arithmetic with infinity:

Operation Result
x + Infinity Infinity (for finite x)
Infinity + Infinity Infinity
Infinity - Infinity NaN
Infinity * 0 NaN
Infinity * Infinity Infinity
x / Infinity 0 (for finite x)
Infinity / Infinity NaN

Comparison behavior:

  • Infinity > x is true for any finite x
  • -Infinity < x is true for any finite x
  • Infinity === Infinity is true
  • isFinite(Infinity) is false

Why infinity exists:

Instead of crashing on overflow, IEEE 754 returns infinity and allows computation to continue. This is often preferable to throwing an exception because downstream code can check for infinity and handle it gracefully. In signal processing and control systems, infinity can represent saturation naturally.

Use Case

Understanding infinity representation is important for implementing robust numerical algorithms, handling edge cases in division and overflow, and debugging unexpected results in scientific computing or financial calculations.

Try It — IEEE 754 Inspector

Open full tool