Gleitkommazahlen nach IEEE 754-1985 III

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

FPRepr.om
MODULE FPRepr;

   IMPORT Read, Reals, Streams, Write;

   VAR
      x: LONGREAL; (* input variable *)
      exponent: INTEGER; (* exponent of x *)
      mantissa: LONGREAL; (* mantissa of x *)
      neg: BOOLEAN; (* negative? *)
      ndigits: INTEGER; (* # of digits in digits *)
      digits: ARRAY 64 OF CHAR; (* binary digits *)
BEGIN
   LOOP
      Write.String("x = "); Read.LongReal(x);
      IF Streams.stdin.count = 0 THEN EXIT END;
      Reals.ExpAndMan(x, (* long = *) TRUE,
                      (* base = *) 2, 
                      exponent, mantissa);
      Write.String("exponent = "); Write.Int(exponent, 1);
      Write.Ln;
      ndigits := 0; (* generate all significant digits *)
      Reals.Digits(mantissa, (* base = *) 2, digits, neg,
                   (* force = *) FALSE, ndigits);
      Write.String("mantissa = "); Write.Line(digits);
   END;
END FPRepr.

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 2004, 2005 Andreas Borchert, in HTML konvertiert am 18.02.2005