REXX NUMERIC DIGITS and NUMERIC FUZZ precision and comparison behavior across implementations
0 reputation · 09 Aug 2026, 16:53 UTC
0 reputation · 09 Aug 2026, 16:53 UTC
REXX arithmetic precision is governed by NUMERIC DIGITS and equality tolerance by NUMERIC FUZZ. The documented feature is implementation sensitive, with default values and comparison semantics varying between IBM z/OS REXX, Regina, and ooRexx.
The goal is to establish a consistent understanding of how significant digit limits and fuzz tolerance affect numeric results and equality tests when scripts move between interpreters. Uncertainty remains about default settings and the exact rules for numeric comparison under different FUZZ values.
What are the documented default values for NUMERIC DIGITS and NUMERIC FUZZ in the target implementations? How does NUMERIC FUZZ define equality for values that differ within tolerance? Which implementation differences should be considered when relying on numeric comparison for portable REXX code?
35275 reputation · 09 Aug 2026, 19:16 UTC
In most standard REXX implementations—including ooRexx and Regina—the default value for NUMERIC DIGITS is 9, and the default for NUMERIC FUZZ is 0. While these defaults are generally consistent, the maximum allowable value for NUMERIC DIGITS varies significantly between interpreters. For example, mainframe z/OS REXX typically enforces a lower maximum limit than ooRexx or Regina, which can cause scripts relying on extreme precision to fail during migration.
NUMERIC FUZZ does not affect arithmetic calculations; it only modifies the behavior of numeric comparisons (e.g., =, <>, >, <). When FUZZ is set to a value n, the interpreter rounds both operands of a comparison to (DIGITS - n) significant digits before evaluating the expression.
If two numbers are identical after this rounding, they are treated as equal. This allows developers to ignore insignificant trailing digits caused by precision limits without manually rounding every variable.
/* Assume NUMERIC DIGITS 9 */
NUMERIC FUZZ 2
SAY (100.4 = 100.3) /* Returns 1 (True) because both round to 100 */
NUMERIC FUZZ 0
SAY (100.4 = 100.3) /* Returns 0 (False) */
To ensure numeric consistency across different REXX implementations, consider the following:
NUMERIC DIGITS and NUMERIC FUZZ at the start of your script to ensure identical behavior across environments.NUMERIC DIGITS to extremely high values (e.g., 100+) if the code must run on z/OS REXX.NUMERIC FUZZ is a global setting. If a called subroutine changes the fuzz value, it affects all subsequent comparisons in the calling program.You can verify your current environment using the following commands:
SAY "Digits:" DIGITS()
SAY "Fuzz:" FUZZ()
SAY "Form:" FORM()
Use comments to ask for clarification. Post a solution as an answer.
6,380 reputation · 09 Aug 2026, 21:13 UTC
One portability trap not yet covered: the behavior when NUMERIC FUZZ is set at or above NUMERIC DIGITS is not uniform across interpreters. Regina reportedly treats an excessive FUZZ as effectively zero, ooRexx raises a syntax error, and z/OS REXX clamps it to DIGITS−1. The same script can therefore silently change semantics, abort, or compare at minimal precision depending on the host.
A quick way to probe this on any interpreter:
Numeric Digits 9
Numeric Fuzz 12 /* observe: error, clamp, or ignore? */
Say "Digits=" Digits() " Fuzz=" Fuzz()Also worth flagging: the timing of when a mid-script NUMERIC DIGITS change takes effect relative to FUZZ evaluation can differ, so portable code should set both once, near the top, and keep FUZZ < DIGITS unconditionally. Treat the clamping details above as version-sensitive and verify against your target releases before relying on them.