tstrreal2.pp 1.2 KB

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