ex69.pp 955 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Program Example68;
  2. { This program demonstrates the FloatToStrF function }
  3. Uses sysutils;
  4. Const Fmt : Array [TFloatFormat] of string[10] =
  5. ('general','exponent','fixed','number','Currency');
  6. Procedure Testit (Value : Extended);
  7. Var I,J : longint;
  8. FF : TFloatFormat;
  9. S : ShortString;
  10. begin
  11. For I:=5 to 15 do
  12. For J:=1 to 4 do
  13. For FF:=ffgeneral to ffcurrency do
  14. begin
  15. Write (Value,'(Prec: ',I:2,', Dig: ',J,', fmt : ',Fmt[ff],') : ');
  16. SetLength(S,FloatToText (@S[1],Value,FF,I,J));
  17. Writeln (S);
  18. Write (-Value,'(Prec: ',I:2,', Dig: ',J,', fmt : ',Fmt[ff],') : ');
  19. SetLength(S,FloatToText (@S[1],-Value,FF,I,J));
  20. Writeln (S);
  21. end;
  22. end;
  23. Begin
  24. Testit (1.1);
  25. Testit (1.1E1);
  26. Testit (1.1E-1);
  27. Testit (1.1E5);
  28. Testit (1.1E-5);
  29. Testit (1.1E10);
  30. Testit (1.1E-10);
  31. Testit (1.1E15);
  32. Testit (1.1E-15);
  33. Testit (1.1E100);
  34. Testit (1.1E-100);
  35. End.