home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol133 / flptdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1984-04-29  |  2.7 KB  |  102 lines

  1. Program FLPTDEMO(0);
  2. {$IFLPTCONS.PAS  }
  3. {$IFLPTTYPE.PAS  }
  4. {$IFLPTVAR.PAS   }
  5.     i        : integer;
  6.     alfa, beta    : extdatum;
  7.     k, l, a, b, c, d: newreal;
  8.     continue    : boolean;
  9.     ch        : char;
  10. {$IFLPTEXT.PAS   }
  11.  
  12. begin
  13. {insert here clear screen}
  14. mode := rounded;
  15. writeln('          EXTENDED PRECISION FLOATING POINT PACKAGE');
  16. writeln('               DEMONSTRATION PROGRAM');
  17. writeln;
  18. writeln;
  19. writeln('Enter the first operand by typing a string of consecutive digits');
  20. writeln(
  21. '(up to but no more than ',prec:1,' ) optionally preceeded by either "+" or');
  22. writeln('"-" and followed by "E" or "e" and then by the exponent. ');
  23. writeln('The number may contain a decimal point as in any standard Pascal');
  24. writeln('implementation. Leading zeros are discarded.');
  25. writeln('Note that :');
  26. writeln('   the absence of sign results in a positive number;');
  27. writeln('   the exponent should consist of a signed or unsigned number');
  28. writeln('   with one, two or three digits.');
  29. writeln('After any operand has been composed, type twice return to indicate');
  30. writeln('completion.');
  31. writeln;
  32. continue := true;
  33. repeat
  34. writeln('Enter the first operand.');
  35. do_read(alfa, k);
  36. writeln;
  37. writeln('Enter the second operand.');
  38. writeln;
  39. do_read(beta, l);
  40. writeln;
  41. writeln;
  42. write('The first operand is equal to  : ');
  43. if alfa.s = plus then write('+') else write('-');
  44. write(alfa.f[1]:1, '.');
  45. for i := 2 to prec do write(alfa.f[i]:1);
  46. if alfa.f[1] <> 0 then
  47.     begin
  48.     write('E');
  49.     if (alfa.e-1) < 0 then write('-') else write('+');
  50.     if abs(alfa.e-1) < 10 then write('0');
  51.     writeln(abs(alfa.e-1):1)
  52.     end
  53.   else
  54.     writeln('+00');
  55. writeln;
  56. write('The second operand is equal to : ');
  57. if beta.s = plus then write('+') else write('-');
  58. write(beta.f[1]:1, '.');
  59. for i := 2 to prec do write(beta.f[i]:1);
  60. if beta.f[1] <> 0 then
  61.     begin
  62.     write('E');
  63.     if (beta.e-1) < 0 then write('-') else write('+');
  64.     if abs(beta.e-1) < 10 then write('0');
  65.     writeln(abs(beta.e-1):1)
  66.     end
  67.   else
  68.     writeln('+00');
  69. writeln;
  70. a := add(k, l);
  71. b := sub(k, l);
  72. c := multp(k, l);
  73. d := divde(k, l);
  74. write('The sum of the first and the second operand is :        ');
  75. do_write(a);
  76. writeln;
  77. writeln;
  78. write('The difference of the first and the second operand is : ');
  79. do_write(b);
  80. writeln;
  81. writeln;
  82. write('The product of the first and the second operand is :    ');
  83. do_write(c);
  84. writeln;
  85. writeln;
  86. write('The quotient of the first and the second operand is :   ');
  87. do_write(d);
  88. writeln;
  89. writeln;
  90. writeln;
  91. writeln('Type "T" to terminate the program. Press any other key to continue.');
  92. read(ch);
  93. if ch = 'T' then continue := false
  94. until continue = false;
  95. writeln;
  96. writeln;
  97. writeln('WARNING : Roundoff errors may affect the least significant digit(s).');
  98. writeln;
  99. writeln;
  100. writeln('                    END OF THE DEMONSTRATION PROGRAM');
  101. end.
  102.