Pārlūkot izejas kodu

Merged revisions 12323 via svnmerge from
svn+ssh://svn.freepascal.org/FPC/svn/fpc/trunk

........
r12323 | michael | 2008-12-10 21:39:16 +0100 (Wed, 10 Dec 2008) | 1 line

* And once more fixed formatfloat. All results consistent with Delphi now
........

git-svn-id: branches/fixes_2_2@12324 -

michael 17 gadi atpakaļ
vecāks
revīzija
3178e14abd
1 mainītis faili ar 11 papildinājumiem un 9 dzēšanām
  1. 11 9
      rtl/objpas/sysutils/sysstr.inc

+ 11 - 9
rtl/objpas/sysutils/sysstr.inc

@@ -1950,8 +1950,10 @@ Var
       Width:=Placehold[1]+Placehold[2]+Decimals;
       If (Decimals=0) Then
         Str(Value:Width:0,Digits)
-      Else
-        Str(Value:Width+1:Decimals,Digits);
+      Else if Value>=0 then
+        Str(Value:Width+1:Decimals,Digits)
+      else
+        Str(Value:Width+2:Decimals,Digits);
       len:=Length(Digits);
       { Find the decimal point }
       If (Decimals=0) Then
@@ -1980,19 +1982,19 @@ Var
         places, remove decimal point. }
       If (DecimalPoint < len) And (Digits[DecimalPoint + 1] = ' ') Then
           Digits[DecimalPoint] := ' ';
-      { Convert spaces left from obligatory decimal point to zeroes. }
+      { Convert spaces left from obligatory decimal point to zeroes. 
+        MVC : If - sign is encountered, replace it too, and put at position 1}
       I:=DecimalPoint-Placehold[2];
-      If (Value<0) and (I<DecimalPoint) and (Digits[1]<>'-') then
-        begin
-        Insert('-',Digits,I);
-        Inc(DecimalPoint);
-        Inc(I);
-        end;
+      J:=0;
       While (I<DecimalPoint) And (Digits[I] in [' ','-']) Do
         Begin
+        If Digits[i]='-' then
+          J:=I;
         Digits[I] := '0';
         Inc(I);
         End;
+      If (J<>0) then
+        Digits[1]:='-';
       Exp := 0;
       End
     Else