Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!rpi!bu.edu!xylogics!merk!alliant!linus!nixbur!nixpbe!peun11!josef From: josef@nixpbe.UUCP (Moellers) Newsgroups: comp.lang.modula2 Subject: Intermediate format of FP numbers Summary: What FP format should one use in an intermediate file? Keywords: compiler, lexical analyzer, floating point numbers Message-ID: Date: 18 Jul 90 14:00:55 GMT Sender: news@nixpbe.UUCP Distribution: comp Lines: 34 Hi, I'm about to start to write a Modula-2 compiler as none of my machines has one (apart from my ZCPR33 box, but that doesn't count). I want to build a highly modular, multi-stage compiler, much like Per Brinch Hansen's Edison compiler published in his book "Programming a personal computer". The first stage, lexical analysis, transforms the character string making up the source file into an intermediate file consisting of tokens and "arguments" to these tokens. E.g. the fragment x := 6; would be translated into the sequence of tokens and "arguments" IDENT x BECOMES INTEGER 6 SEMICOLON (where x is a number identifying identifier "x", e.g. 5) which could be stored as the bytes 1 0 0 0 5 2 3 0 0 0 1 4 | | | | | | | | | | | +- Token SEMICOLON | | | | | | | +-+-+-+--- binary value of integer 1, MSB first | | | | | | +----------- Token INTEGER | | | | | +------------- Token BECOMES | +-+-+-+--------------- binary value of number identifying "x" +----------------------- Token IDENTIFIER Question: what format should I use for floating point numbers? I do not want to loose precision during this phase. On the other hand, I would like to use some standard format! Would IEEE double precision be enough? -- | Josef Moellers | c/o Nixdorf Computer AG | | USA: mollers.pad@nixbur.uucp | Abt. PXD-S14 | | !USA: mollers.pad@nixpbe.uucp | Heinz-Nixdorf-Ring | | Phone: (+49) 5251 104662 | D-4790 Paderborn |