Explorar o código

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

git-svn-id: trunk@7959 -
Jonas Maebe %!s(int64=18) %!d(string=hai) anos
pai
achega
1eb1bf4c42
Modificáronse 2 ficheiros con 8 adicións e 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
             factor := factor * 10.0;
           corrval := corrval / factor;
-          if d >= corrVal then
+          if d >= corrVal-roundCorr then
             d := d + corrVal;
-          if int(d) = 1 then
+          if int(d+roundCorr) = 1 then
             begin
               roundStr(temp,spos);
               d := frac(d);

+ 6 - 0
tests/test/tstrreal3.pp

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