Floating-Point Sorts
Standard Formats
Create standard IEEE 754 floating-point sorts:Z3_mk_fpa_sort_16(c)- half precision (api_fpa.cpp:182)Z3_mk_fpa_sort_32(c)- single precision (api_fpa.cpp:190)Z3_mk_fpa_sort_64(c)- double precision (api_fpa.cpp:198)Z3_mk_fpa_sort_128(c)- quadruple precision (api_fpa.cpp:206)
Custom Formats
Create custom floating-point formats:Z3_mk_fpa_sort(c, ebits, sbits) (api_fpa.cpp:164)
Rounding Modes
IEEE 754 defines five rounding modes:Z3_mk_fpa_rne(c)- round nearest ties to even (api_fpa.cpp:64)Z3_mk_fpa_rna(c)- round nearest ties away (api_fpa.cpp:86)Z3_mk_fpa_rtp(c)- round toward positive (api_fpa.cpp:108)Z3_mk_fpa_rtn(c)- round toward negative (api_fpa.cpp:130)Z3_mk_fpa_rtz(c)- round toward zero (api_fpa.cpp:152)
Special Values
NaN (Not a Number)
Z3_mk_fpa_nan(c, s) (api_fpa.cpp:210)
Infinity
Z3_mk_fpa_inf(c, s, negative) (api_fpa.cpp:226)
Zero
Floating-point has both positive and negative zero:Z3_mk_fpa_zero(c, s, negative) (api_fpa.cpp:243)
Floating-Point Literals
From Decimal
Z3_mk_fpa_numeral_float(c, v, ty)(api_fpa.cpp:275)Z3_mk_fpa_numeral_double(c, v, ty)(api_fpa.cpp:295)
From IEEE Bit Representation
Construct from sign, exponent, and significand bits:Z3_mk_fpa_fp(c, sgn, exp, sig) (api_fpa.cpp:260)
Arithmetic Operations
All floating-point operations require a rounding mode:Addition
Subtraction
Multiplication
Division
Remainder
Fused Multiply-Add
Compute (x * y) + z with single rounding:Square Root
Absolute Value and Negation
Min and Max
Comparison Operations
Equality and Inequality
Ordered Comparisons
IEEE Predicates
Conversion Operations
Between Floating-Point Formats
To/From Real
To/From Integers
To/From Bit-Vectors
Complete Examples
Example 1: Rounding Error
Example 2: Division by Zero
Example 3: Overflow Detection
Example 4: Precision Loss
Example 5: NaN Propagation
Example 6: Correctly Rounded Result
Advanced Features
Subnormal Numbers
Numbers smaller than the smallest normalized number:Rounding Mode Effects
Implementation Notes
- Follows IEEE 754-2008 standard precisely
- All operations require explicit rounding modes
- NaN propagates through computations
- Special handling for signed zeros
- Supports directed rounding for interval arithmetic
References
- Implementation:
src/api/api_fpa.cpp - Theory plugin:
src/ast/fpa_decl_plugin.h - Solver:
src/smt/theory_fpa.h - IEEE 754 Standard: IEEE Standard for Floating-Point Arithmetic (IEEE 754-2008)
