Skip to main content
Z3 provides comprehensive support for IEEE 754 floating-point arithmetic through the FPA (Floating-Point Arithmetic) theory. This allows precise reasoning about floating-point computations, rounding errors, and special values like NaN and infinity.

Overview

Z3’s floating-point support includes:
  • IEEE 754 compliance: Standard binary floating-point formats
  • Rounding modes: All five IEEE 754 rounding modes
  • Special values: NaN, infinity, signed zeros
  • Conversions: Between floating-point, integers, and bit-vectors
  • Arithmetic operations: +, -, *, /, sqrt, fma, etc.
  • Comparisons: Proper handling of NaN and signed zeros

Floating-Point Sorts

Creating Floating-Point Sorts

Floating-Point Values

Rounding Modes

IEEE 754 defines five rounding modes. Z3 supports all of them:

Rounding Mode Effects

Arithmetic Operations

Basic Operations

Rounding Operations

Comparisons and Predicates

Comparison Operations

Predicates

Conversions

To/From Bit-Vectors

To/From Reals and Integers

Format Conversions

Practical Examples

Checking Floating-Point Accuracy

Verifying Numerical Stability

Solving Floating-Point Constraints

C API Reference

Floating-point operations in C:

Key Functions

Common Pitfalls

  1. Forgetting rounding modes: Most operations require explicit rounding mode
  2. NaN comparisons: NaN != NaN (unlike standard equality)
  3. Signed zeros: +0.0 and -0.0 are distinct but compare equal
  4. Precision loss: Converting from higher to lower precision
  5. Overflow/underflow: Results may become infinity or subnormal

See Also