tstrreal2.pp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const
  2. s: array[1..21] of string =
  3. ('10.00000000000000000',
  4. '1.00000000000000000',
  5. '0.10000000000000000',
  6. '0.01000000000000000',
  7. '0.00100000000000000',
  8. '0.00010000000000000',
  9. '0.00001000000000000',
  10. '0.00000100000000000',
  11. '0.00000010000000000',
  12. '0.00000001000000000',
  13. '0.00000000100000000',
  14. '0.00000000010000000',
  15. '0.00000000001000000',
  16. '0.00000000000100000',
  17. '0.00000000000010000',
  18. '0.00000000000001000',
  19. '0.00000000000000100',
  20. '0.00000000000000010',
  21. '0.00000000000000001',
  22. '0.00000000000000000',
  23. '0.00000000000000000');
  24. var
  25. e: extended;
  26. c: longint;
  27. s2: string;
  28. lenadjust: longint;
  29. begin
  30. if sizeof(extended) = 8 then
  31. lenadjust := 2
  32. else
  33. lenadjust := 0;
  34. e := 10.0;
  35. for c := 1 to 21 do
  36. begin
  37. str(e:0:17,s2);
  38. writeln(s2);
  39. if s2 <> copy(s[c],1,length(s[c])-lenadjust) then
  40. begin
  41. writeln(' Error, should be ',copy(s[c],1,length(s[c])-lenadjust));
  42. halt(1);
  43. end;
  44. e := e / 10.0;
  45. end;
  46. end.