fpc/tests/test/units/system/tgenstr.pp
Jonas Maebe 21eeec9981 + re-implementation of real->string and string->real conversion routines
based on the Grisu1 algorithm. This corrects several precision issues
    with the previous code used to perform such conversions (patch by
    Max Nazhalov, mantis #25241)
   o adaptation of several tests to deal with the better precision of these
     routines compared to the previous version
  Please don't remove the real2str.inc file yet, it's still used by the
  JVM target for now

git-svn-id: trunk@25888 -
2013-10-31 12:39:27 +00:00

37 lines
1.0 KiB
ObjectPascal

{ %norun }
uses
math;
var
drec : record
d1,d2 : dword;
end;
i,j : longint;
s : string;
d : double absolute drec;
begin
randomize;
SetExceptionMask([exInvalidOp,exDenormalized,exZeroDivide,exOverflow,exUnderflow,exPrecision]);
writeln('{ Generated by FPC ',{$I %FPCVERSION%},' using tgenstr.pp }');
writeln('uses math; procedure c(d : double;const s : string);');
writeln('var hs : string;begin str(d:22,hs); if hs<>s then begin writeln(''expected: "'',s,''", got: "'',hs,''"''); halt(1); end; end;');
for j:=1 to 1 do
begin
writeln('procedure p',j,'; begin');
for i:=1 to 5000 do
begin
drec.d1:=random(4294967296);
drec.d2:=random(4294967296);
str(d:22,s);
writeln('c(',d,',''',s,''');');
end;
writeln('end;');
writeln;
end;
writeln('begin');
writeln('SetExceptionMask([exInvalidOp,exDenormalized,exZeroDivide,exOverflow,exUnderflow,exPrecision]);');
for j:=1 to 1 do
writeln('p',j,';');
writeln('writeln(''ok'');');
writeln('end.');
end.