t100_realexpr.pas 704 B

12345678910111213141516171819202122232425262728293031323334353637
  1. program t100_realexpr;
  2. { t100 -- REAL literals, comparisons and + - * /. The runtime's MBF
  3. arithmetic entries do the work; the compiler packs each operation into a
  4. 12-byte block and keeps the result address as a REAL value. }
  5. type
  6. R = record
  7. V : real;
  8. end;
  9. var
  10. A, B, C : R;
  11. S : string[20];
  12. begin
  13. A.V := 2;
  14. B.V := 3;
  15. C.V := A.V + B.V;
  16. Str (C.V : 0 : 0, S);
  17. writeln (S);
  18. C.V := B.V - A.V;
  19. Str (C.V : 0 : 0, S);
  20. writeln (S);
  21. C.V := A.V * B.V;
  22. Str (C.V : 0 : 0, S);
  23. writeln (S);
  24. C.V := B.V / A.V;
  25. Str (C.V : 0 : 1, S);
  26. writeln (S);
  27. A.V := 1.5;
  28. Str (A.V : 0 : 1, S);
  29. writeln (S);
  30. if A.V < B.V then
  31. writeln ('TRUE')
  32. else
  33. writeln ('FALSE')
  34. end.