Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!natinst!sequoia!rpp386!aubrey From: aubrey@rpp386.cactus.org (Aubrey McIntosh) Newsgroups: comp.lang.modula2 Subject: Re: Intermediate format of FP numbers Keywords: compiler, lexical analyzer, floating point numbers Message-ID: <18459@rpp386.cactus.org> Date: 21 Jul 90 05:10:12 GMT References: <10068@brazos.Rice.edu> Reply-To: aubrey@rpp386.UUCP (Aubrey McIntosh) Distribution: comp Organization: vima, Austin TX Lines: 55 In article <10068@brazos.Rice.edu> preston@titan.rice.edu (Preston Briggs) writes: >One reasonable way to proceed is to *not* convert the numbers. >Instead, keep the string representation and pass it along from phase >to phase. This has the advantages of never losing precision, >saving FP arithmetic, making your intermediate code simpler >Preston Briggs looking for the great leap forward I have just written a program 'ToInteger' that takes a file of numbers of the form [+|-][digit][.][digit][e|E][integer] and makes them simpler. 1.00E+002 --> 100 9e2 --> 900 (padding with 0) 005 --> 5 (implied decimal point alignment) 10.001e4 --> 100.01e3 (exact digit preservation) 0010.0010e4 --> 100.01e3 (leading/trailing 0 suppression) 0 --> 00 (known bug.) 00 --> 00 (not perverse, however) I have a structure similar to: RECORD negative : BOOLEAN; decimalBeforeDigit : CARDINAL; exponent : INTEGER; mantissa : string; (*string is currently ARRAY [0..max-1] OF CHAR*) END; (is it possible to use VI to write Modula-2? :-) ) As soon as I finish a little problem using InOut (Logitech 3.3t) and redirected input, I'll post it. Help is welcome... ------------------------------- I'd like to have RealInOut print the numbers in engineering format, (powers of 1000 for exponent. No, wait, that's multiples of 3...) The smaller exponents, -21 .. 21, would be replaced with single letters rather than E+nnn. e.g.: 1E-009 --> 1n 1E-006 --> 1u 1E-003 --> 1m 1E+000 --> 1 Has anyone else done this? Would people want the diffs? What's smaller than femto and ato? Are there suggestions for large exponents, e-99. -- Aubrey McIntosh "Find hungry samurai." -- The Old Man 1502 Devon Circle comp.os.minix, comp.lang.modula2 Austin, TX 78723 1-(512)-452-1540 (v)