Explorar el Código

* fixed str(extended(0.005):0:2) and related problems

git-svn-id: trunk@7959 -
Jonas Maebe hace 18 años
padre
commit
1eb1bf4c42
Se han modificado 2 ficheros con 8 adiciones y 2 borrados
  1. 2 2
      rtl/inc/real2str.inc
  2. 6 0
      tests/test/tstrreal3.pp

+ 2 - 2
rtl/inc/real2str.inc

@@ -378,9 +378,9 @@ begin
           for fracCount := 1 to currPrec do
           for fracCount := 1 to currPrec do
             factor := factor * 10.0;
             factor := factor * 10.0;
           corrval := corrval / factor;
           corrval := corrval / factor;
-          if d >= corrVal then
+          if d >= corrVal-roundCorr then
             d := d + corrVal;
             d := d + corrVal;
-          if int(d) = 1 then
+          if int(d+roundCorr) = 1 then
             begin
             begin
               roundStr(temp,spos);
               roundStr(temp,spos);
               d := frac(d);
               d := frac(d);

+ 6 - 0
tests/test/tstrreal3.pp

@@ -45,6 +45,12 @@ begin
  writeln(result);
  writeln(result);
  if (result <> '8.502') then
  if (result <> '8.502') then
    halt(1);
    halt(1);
+
+ e:=0.005;
+ str(e:0:2,result);
+ writeln(result);
+ if (result<>'0.01') then
+   halt(1);
 end;
 end;
 
 
 begin
 begin