OBERON FOR MS-DOS System 3 This file contains all the changes made for the current release. 14. 6. 93 Version 1.2 Improved real arithmetic (see below) Start of this file. AN IMPROVED IMPLEMENTATION OF THE FLOATING-POINT CONVERSION The floating-point handling has been improved in the Oberon implementation that is shipped with this note. The original version of Oberon, as published in [1] suffer from the following deficiencies: 1) The floating-point numbers from a source file which are scanned by the compiler and floating-point numbers read in from a text file by Texts.Scan are not necessarily identical. The bit pattern differs in the least significant part. Furthermore, the decimal-to-binary conversion is inaccurate. 2) The trap handler prints fewer decimal digits of REALs and LONGREALs than significant. 3) The two least significant digits (7-8 for REALs and 15-16 for LONGREALs) are often wrong. 4) The procedure Texts.WriteRealFix has the same deficiencies as Texts.WriteReal; moreover it traps for some parameters. 5) For floating-point numbers with certain binary exponents (listed subsequently), the decimal exponent printed is wrong by one decimal unit! For example: all floating-point numbers x with 2^-103 <= x < 2^-102 are printed with a wrong exponent. REALs: wrong correct 2^-103 9.8607620E-31 9.8607613E-32 2^-113 9.6296500E-34 9.6296497E-35 2^-123 9.4039550E-37 9.4039548E-38 LONGREALs: (totally 132 cases) wrong correct 2^-103 9.860761315262652D-031 9.860761315262648D-032 2^-113 9.629649721936183D-034 9.629649721936179D-035 2^-123 9.403954806578305D-037 9.403954806578299D-038 ... 2^-1017 7.120236347223050D-306 7.120236347223044D-307 2^-1020 8.900295434028810D-307 8.900295434028805D-308 All errors mentioned above are avoided by the new implementation. Since IEEE error codes and denormalized numbers are not always supported, all error codes are printed as "NaN" (Not-a-Number) and denormalized numbers are flushed to zero. Besides, the functionality of the WriteRealFix has been redesigned, and WriteLongRealFix has been added: Description: PROCEDURE WriteLongRealFix* (VAR W: Writer; x: LONGREAL; n, f, D: LONGINT); The parameters are: W a Texts.Writer x the LONGREAL number to be printed n the overall field length available for the output f the number of fraction digits following the decimal point D the fixed exponent (printed only when D # 0) Example: The following program excerpt e:= -310; WHILE e <= -277 DO Texts.WriteInt(W, e, 2); Texts.WriteLongRealFix(W, -1.234567898765432D-300,30,5,e); Texts.WriteLn(W); INC(e) END delivers the following output: -310 NaN -309 NaN -308 -***********************D-308 -307 -***********************D-307 -306 -***********************D-306 -305 -***********************D-305 -304 -***********************D-304 -303 -***********************D-303 -302 -***********************D-302 -301 -***********************D-301 -300 -1.234567898765431000000D-300 -299 -0.123456789876543100000D-299 -298 -0.012345678987654310000D-298 -297 -0.001234567898765431000D-297 -296 -0.000123456789876543100D-296 -295 -0.000012345678987654310D-295 -294 -0.000001234567898765432D-294 -293 -0.000000123456789876543D-293 -292 -0.000000012345678987654D-292 -291 -0.000000001234567898765D-291 -290 -0.000000000123456789877D-290 -289 -0.000000000012345678988D-289 -288 -0.000000000001234567899D-288 -287 -0.000000000000123456790D-287 -286 -0.000000000000012345679D-286 -285 -0.000000000000001234568D-285 -284 -0.000000000000000123457D-284 -283 -0.000000000000000012346D-283 -282 -0.000000000000000001235D-282 -281 -0.000000000000000000123D-281 -280 -0.000000000000000000012D-280 -279 -0.000000000000000000001D-279 -278 -0.000000000000000000000D-278 -277 -0.000000000000000000000D-277 The least significant non zero digit (in this example: 1 resp. 2 when D >= -300) has an error of at most 2 decimal units caused by the rounding error in the least significant bit of 10^D and the subsequent multiplication with the mantissa. All the computations in the floating-point units are done correctly. The testing of the modules Math and MathL is in progress. For further information or remarks please contact either the corresponding implementor at the Institut fr Computersysteme ETH, 8092 Zrich, Switzerland, Telephone (1)254 7311, Facsimile (1)262 3973 or the author of this note. Reference [1] N. Wirth and J. Gutknecht: Project Oberon. The Design of an Operating System and Compiler. Addison Wesley, 1992, ISBN 0-201-54428-8. Program listings with explanations for the whole Oberon system, including the compiler for NS32000. Bernd Moesli moesli@sam.math.ethz.ch Seminar for Applied Mathematics Swiss Federal Institute of Technology Zurich ETH-Zentrum Fliederstr. 23 CH-8092 Zuerich, Switzerland BM 1993.3.15 Copyright 1993