t92_strreal.pas 838 B

12345678910111213141516171819202122232425262728293031323334
  1. program t92_strreal;
  2. { t92 -- Str(real:width:decimals, S). CALC.INC's Print calls
  3. Str(Value:FW:DEC,P)
  4. where Value is a REAL field, FW and DEC are integer fields/variables, and
  5. P is a string. The runtime's real_fmt already produces the padded,
  6. length-prefixed field; this fixture pins the compiler's argument packing
  7. and both widths/decimals. The outputs are derived from real_fmt's
  8. measured behaviour (the same rules as t84_realwrite): field width 8 with
  9. 2 decimals is ' 3.00'; width 0 is '3.00'; width 10 with 0 decimals
  10. pads 3 to ten columns. }
  11. type
  12. RealRec = record
  13. R : real;
  14. end;
  15. var
  16. X : RealRec;
  17. S : string[20];
  18. W, D : integer;
  19. begin
  20. X.R := 3;
  21. W := 8;
  22. D := 2;
  23. Str (X.R : W : D, S);
  24. writeln (S);
  25. Str (X.R : 0 : 2, S);
  26. writeln (S);
  27. Str (X.R : 10 : 0, S);
  28. writeln (S)
  29. end.