I propose adding a new function to System Math. This function would satisfy the equation
x = Floor(x) + Fraction(x) in a similar way that the existing function Frac satisfies x = Trunc(x) + Frac(x).
The changes to Mod/Math, Mod/SMath, Docu/Math & Rsrc/Strings are in the panel below.
This has worked reliably for me for years.
Code: Select all
PROCEDURE Fraction* (x: REAL): REAL;
BEGIN
(* 20, x # INF & x # -INF *)
FLD(x); FLDst0; FRNDINT;
FCOM; FSWax; SAHF; JBE4; FLD1; FSUB;
FSUB; WAIT; RETURN TOP()
END Fraction;
PROCEDURE Fraction* (x: SHORTREAL): SHORTREAL;
BEGIN
(* 20, x # INF & x # -INF *)
FLD(x); FLDst0; FRNDINT;
FCOM; FSWax; SAHF; JBE4; FLD1; FSUB;
FSUB; WAIT; RETURN TOP()
END Fraction;
PROCEDURE Fraction (x: REAL): REAL;
You could easily implement the functions Sign, Floor, Ceiling, Trunc, Frac, Fraction, and Round yourself, using the ENTIER standard function.
PROCEDURE Fraction (x: REAL): REAL
Frac is the fractional part of the argument.
The following equation holds: x = Floor(x) + Fraction(x), within the limits of 64-bit floating point arithmetic.
Pre
x # INF & x # -INF 20
Math.Fraction.143 Pre: x # INF & x # -INF