Alto/Mesa Floating Point Packages1c Xerox Corporation 1980Alto/Mesa Floating Point PackagesOctober 11, 1979Read this carefully! There is a lot of information hidden away here.FLOAT, FLOATIO, FLOATFNS, and FLOATDEBUG contain procedures that implement various operations onREALs. FLOAT must be STARTed (see InitFloat below); it stuffs the appropriate locations in the systemdispatch vector so that REAL operations will be defined, and must be present for all the other packages.The necessary TYPE and PROCEDURE declarations appear in RealDefs and FloatFnDefs and are describedbelow. Three error conditions cause the signal FloatingPointError of type FloatingError. These are:division by 0, exponent overflow (x NOT IN[-2127..2127], and exponent overflow from Fix (floatingpoint value is outside the range of the destination type). RESUMEing from this signal will return from thefloating point operation with a 'reasonable' value.There are two versions of these packages. One has microcode implementations of the floating pointoperations and can only be used on Alto II's with Mesa ROMs or 3K CRAM. The other version hasBCPLCode operations and will run on any Alto. There are also two versions of RealDefs, one of whichhas INLINE microcode calls for Fix, FixI, and FixC, and the other of which does not. The INLINE versionis compatible with the microcode floating point.Fine point about the signal FloatingPointError: Mesa 5.0 implements the ENABLE clause by placing a catch phrase on everyprocedure call within the enabled block. Because of this, an ENABLE FloatingPointError on a block containing floating pointoperations will not catch signals generated by those operations, but it will catch signals generated by floating point operationsexecuted within procedures called from inside the block. This nuance causes BCPL-Float and uCode-Float to behave in slightlydifferent ways -- the BCPL-Float version of Fix is a procedure call, so an ENABLE clause on a block containg Fix will work,but the Fix in uCode-Float is an Inline call to microcode, so the ENABLE will not work. Fine point about FloatDebug: The only version of FloatDebug uses the non-microcode floating point operations. This isbecause the correct microcode Ram image could conceivably not be loaded when the debugger swaps in. Do not useFloatDebug anywhere except with the debugger, equivalent procedures are available in FloatIO. The file MakeFloatDebug.cmin FloatDebug.dm is only a suggested command file for installing the debugger, XMesa users may wish to add XCoreMap.The file BCPL-Float.dm contains everything needed for the non-microcode version; uCode-Float.dmcontains everything needed for the microcode version. FloatDebug.dm contains the modules needed forDebugger access to REALs. All sources are in FloatSources.dm. If you use floating point at all, you mustinclude Float.bcd in your configuration. If you read and print floats, you must include FloatIO.bcd. Ifyou use any of the procedures in FloatFnDefs, you must include FloatFns.bcd. These are the onlyrequired modules.in FLOAT: (exports RealDefs)FloatingError: TYPE = {noError,FixRangeOverflow,ExponentOverflow,DivideBy0}; fp!K#qrX!#Yp!&Vr QE NFsrs r* Lsrsrsrt r: Jsr($ IP urursr G #prp r E "FHEFHE+ D107.WFWriteFloat: PROCEDURE [rp: UNSPECIFIED, f: STRING, p: PROCEDURE [CHARACTER]];WFWriteEFloat: PROCEDURE [rp: UNSPECIFIED, f: STRING, p: PROCEDURE [CHARACTER]];These procedures are intended for use with the WriteFormatted package via the SetCodeprocedure. The UNSPECIFIED is treated as a POINTER TO REAL. The PROCEDURE [CHARACTER] isused to print the output. The STRING is a format control string of the form "[lf][.[rf]]" wherebrackets indicate options. Lf is the total allowed field width, rf is the number of fractional digitsto print, and the minus sign indicates left justification. If either lf or rf is 0, as many digits asare appropriate will be printed. WFWriteEFloat forces the output to be in scientific notation,otherwise scientific notation is used whenever the number is <10-4 or >107.ReadFloat: PROCEDURE RETURNS [REAL];Reads a REAL number from the default input stream (using IODefs.ReadID). The input maybe in scientific notation.StringToFloat: PROCEDURE [s: STRING] RETURNS [REAL];Like ReadFloat, but termination is also caused by reaching the end of the string. fp!K bwXxpw ^pwuw[yrFY SX2;sVcU*/ QpwXuFwXxFwNr sr<L IpwXuFwXxw GpwuFwXxwCrsr srsrB%E1=/tX 9p wuwuw 7fp wuwuF w4rsr@2)sr922)0;00; -p wXuwuF1w *p wXuwuF1w'irU%s rsrsr$sr'"s9- \ %H7@77 pwXuFwXuwrQ p wXuwxFuwXuwuwUrQ  <Y\Alto/Mesa Floating Point Packages3in FloatFns: (exports FloatFnDefs)Exp: PROCEDURE [REAL] RETURNS [REAL];For an input argument n, returns en (e=2.718...). (computed by continued fractions).Log: PROCEDURE [base,arg: REAL] RETURNS [REAL];Computes logarithm to the base base of arg (by Ln(arg)/Ln(base)).Ln: PROCEDURE [REAL] RETURNS [REAL];Computes the natural logarithm (base e) of the input argument.SqRt: PROCEDURE [REAL] RETURNS [REAL];Calculates the square root of the input value by Newton's iteration.Root: PROCEDURE [index,arg: REAL] RETURNS [REAL];Calculates the indexth root of arg by e(Ln(arg)/index).Power: PROCEDURE [base,exponent: REAL] RETURNS [REAL];Calculates base to the exponent power by e(exponent*Ln(base)).Sin: PROCEDURE [radians: REAL] RETURNS [REAL];SinDeg: PROCEDURE [degrees: REAL] RETURNS [REAL];Cos: PROCEDURE [radians: REAL] RETURNS [REAL];CosDeg: PROCEDURE [degrees: REAL] RETURNS [REAL];Tan: PROCEDURE [radians: REAL] RETURNS [REAL];TanDeg: PROCEDURE [degrees: REAL] RETURNS [REAL];Computes the trigonometric function by polynomial; good to 7.33 decimal places.ArcTan: PROCEDURE [y, x: REAL] RETURNS [radians: REAL];ArcTanDeg: PROCEDURE [y, x: REAL] RETURNS [degrees: REAL];Good to 8.7 decimal places.in FloatDebug: (exports DebugRealDefs; when loaded with your debugger, the debugger will print REALsnumerically). These are the same procedures as AppendFloat and StringToFloat in FloatIO.AppendRealNumber: PROCEDURE [s: STRING,R: REAL];Converts R to a STRING, and appends this STRING to the input STRING s. fp!K1`vtX" ](puFYr"ZfY2 VpXup upuFpupS IPpXupupuFpupFrD BpXuFp XupuFpup?drpr pr??d <pXupupuFpup8r prpr 9S8 5xpuF pXupuFpup 2u pX upuFpup 0u pX upuFpup .u pX upuFpup +u pX upuFpup )u pX upuFpup%rO "spuF pXupuFpXup uF pXupuFpXupr1tXd1 0r tr t puForsrsr sr ( O=j OAeQ TIMESROMAN MATH  TIMESROMAN  TIMESROMAN TIMESROMAN  TIMESROMAN TIMESROMAN HELVETICA  HELVETICA  HELVETICA j/U float.bravo Larry StewartMay 23, 1980 2:26 PM