(* SAC Rational number definition module. *) DEFINITION MODULE SACRN; FROM MASSTOR IMPORT LIST; PROCEDURE RIRNP(I,CL: LIST): LIST; (*Rational interval rational number product. I is an interval with rational endpoints. c is a rational number. J is the interval I*c.*) PROCEDURE RNABS(R: LIST): LIST; (*Rational number absolute value. R is a rational number. S is the absolute value of R.*) PROCEDURE RNCEIL(RL: LIST): LIST; (*Rational number, ceiling of. r is a rational number. a=CEILING(r), an integer.*) PROCEDURE RNCOMP(R,S: LIST): LIST; (*Rational number comparison. R and S are rational numbers. t=SIGN(R-S).*) PROCEDURE RNDEN(R: LIST): LIST; (*Rational number denominator. R is a rational number. b is the denominator of R, a positive integer.*) PROCEDURE RNDIF(R,S: LIST): LIST; (*Rational number difference. R and S are rational numbers. T=R-S.*) PROCEDURE RNDWR(R,NL: LIST); (*Rational number decimal write. R is a rational number. n is a non-negative integer. R is approximated by a decimal fraction D with n decimal digits following the decimal point and D is written in the output stream. The inaccuracy of the approximation is at most (1/2)*10**-n. If ABS(D) is greater than ABS(R) then the last digit is followed by a minus sign, if ABS(D) is less than ABS(R) then by a plus sign.*) PROCEDURE RNFCL2(AL: LIST; VAR ML,NL: LIST); (*Rational number floor and ceiling of logarithm, base 2. a is a non- zero rational number. m=FLOOR(LOG2(ABS(a))) and n=CEILING(LOG2(ABS(a))) are gamma-integers.*) PROCEDURE RNFLOR(RL: LIST): LIST; (*Rational number, floor of. r is a rational number. a=FLOOR(r), an integer.*) PROCEDURE RNINT(A: LIST): LIST; (*Rational number from integer. A is an integer. R is the rational number A/1.*) PROCEDURE RNINV(R: LIST): LIST; (*Rational number inverse. R is a non-zero rational number. S=1/R.*) PROCEDURE RNNEG(R: LIST): LIST; (*Rational number negative. R is a rational number. S=-R.*) PROCEDURE RNNUM(R: LIST): LIST; (*Rational number numerator. R is a rational number. a is the numerator of R, an integer.*) PROCEDURE RNPROD(R,S: LIST): LIST; (*Rational number product. R and S are rational numbers. T=R*S.*) PROCEDURE RNP2(KL: LIST): LIST; (*Rational number power of 2. k is a gamma-integer. r=2**k, a rational number.*) PROCEDURE RNQ(R,S: LIST): LIST; (*Rational number quotient. R and S are rational numbers, S non-zero. T=R/S.*) PROCEDURE RNRAND(NL: LIST): LIST; (*Rational number, random. n is a positive beta-integer. Random integers A and B are generated using IRAND(n). Then R=A/(ABS(B)+1), reduced to lowest terms.*) PROCEDURE RNREAD(): LIST; (*Rational number read. The rational number R is read from the input stream. Any preceding blanks are skipped.*) PROCEDURE RNRED(A,B: LIST): LIST; (*Rational number reduction to lowest terms. A and B are integers, B non-zero. R is the rational number A/B in canonical form.*) PROCEDURE RNSIGN(R: LIST): LIST; (*Rational number sign. R is a rational number. s=SIGN(R).*) PROCEDURE RNSUM(R,S: LIST): LIST; (*Rational number sum. R and S are rational numbers. T=R+S.*) PROCEDURE RNWRIT(R: LIST); (*Rational number write. R is a rational number. R is converted to decimal and written in the output stream.*) END SACRN.