R4RS, or the "Revised^4 Report on the Algorithmic Language Scheme," does not mandate the inclusion of floating-point number handling in a Scheme implementation. R4RS, published in 1991, is a relatively minimal standard for Scheme, and it leaves many aspects of numerical computation optional to allow for flexibility in implementations, especially on resource-constrained systems.
Key Points Regarding Floating-Point Numbers in R4RS:
-
Numbers in R4RS:
- R4RS defines a general concept of numbers, which may include exact and inexact numbers. Exact numbers are typically integers and rationals, while inexact numbers are typically floating-point numbers.
- The standard does not require implementations to support inexact (floating-point) numbers. It states that implementations may provide inexact numbers, but it is not mandatory.
-
Exactness and Inexactness:
- R4RS introduces the concept of exactness, where operations on exact numbers should produce exact results when possible, and operations on inexact numbers produce inexact results.
- Floating-point numbers, if supported, are considered inexact. However, the decision to include floating-point arithmetic is left to the implementation.
-
Numerical Operations:
- R4RS defines a set of numerical operations (e.g.,
+, -, *, /, etc.) that must work on the numbers provided by the implementation.
- If an implementation supports inexact numbers, these operations must handle them appropriately, but the standard does not require floating-point support.
-
Optional Features:
- Floating-point numbers are considered an optional feature in R4RS. Implementations are free to support only exact integers or exact rationals without providing floating-point arithmetic.
- For example, an implementation could choose to represent all numbers as exact integers or rationals and not provide any floating-point support, and it would still be R4RS-compliant.
-
Portability Considerations:
- Because floating-point support is not mandated, portable Scheme programs written under R4RS cannot assume the availability of floating-point numbers. Programmers must either restrict themselves to exact arithmetic or explicitly check for inexact number support (e.g., using the
inexact? predicate).
Summary:
R4RS does not mandate floating-point number handling. It allows implementations to support floating-point numbers as inexact numbers, but it is not required. If you are writing portable Scheme code under R4RS, you should not assume floating-point arithmetic is available unless you explicitly verify its presence in the implementation.
If floating-point support is critical for your application, you might want to consider later Scheme standards, such as R5RS, R6RS, or R7RS, which provide more detailed specifications for numerical types, though even in those standards, the exact requirements for floating-point support can vary.