* fixed FormatFloat for non-x86 (mantis 9384)

git-svn-id: trunk@8220 -
This commit is contained in:
Jonas Maebe 2007-08-04 17:38:48 +00:00
parent 4cdd590091
commit 49a545aef2
3 changed files with 18 additions and 4 deletions

1
.gitattributes vendored
View File

@ -8367,6 +8367,7 @@ tests/webtbs/tw9299.pp -text
tests/webtbs/tw9306a.pp -text
tests/webtbs/tw9306b.pp -text
tests/webtbs/tw9309.pp -text
tests/webtbs/tw9384.pp svneol=native#text/plain
tests/webtbs/ub1873.pp svneol=native#text/plain
tests/webtbs/ub1883.pp svneol=native#text/plain
tests/webtbs/uw0555.pp svneol=native#text/plain

View File

@ -1970,11 +1970,13 @@ Var
Str(Value:Width+8,Digits);
{ Find and cut out exponent. Always the
last 6 characters in the string.
-> 0000E+0000 }
I:=Length(Digits)-5;
Val(Copy(Digits,I+1,5),Exp,J);
-> 0000E+0000
*** No, not always the last 6 characters, this depends on
the maximally supported precision (JM)}
I:=Pos('E',Digits);
Val(Copy(Digits,I+1,255),Exp,J);
Exp:=Exp+1-(Placehold[1]+Placehold[2]);
Delete(Digits, I, 6);
Delete(Digits, I, 255);
{ Str() always returns at least one digit after the decimal point.
If we don't want it, we have to remove it. }
If (Decimals=0) And (Placehold[1]+Placehold[2]<= 1) Then

11
tests/webtbs/tw9384.pp Normal file
View File

@ -0,0 +1,11 @@
program test_formatloat;
{$mode objfpc}{$H+}
uses
SysUtils;
var
ef : Extended;
begin
ef := 12;
if (FormatFloat('#.#######E-0',ef) <> '1.2E1') then
halt(1);
end.