mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-15 07:09:16 +02:00
* FloatToStrFIntl is used only internally so we can assume that Value is aligned
git-svn-id: trunk@23311 -
This commit is contained in:
parent
b43b4bb455
commit
6363567fba
@ -1153,6 +1153,11 @@ const
|
|||||||
maxdigits = 15;
|
maxdigits = 15;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{ deactive aligned function for 2.6 }
|
||||||
|
{$ifdef VER2_6}
|
||||||
|
{$macro on}
|
||||||
|
{$define aligned:= }
|
||||||
|
{$endif VER2_6}
|
||||||
Function FloatToStrFIntl(const Value; format: TFloatFormat; Precision, Digits: Integer; ValueType: TFloatValue; Const FormatSettings: TFormatSettings): String;
|
Function FloatToStrFIntl(const Value; format: TFloatFormat; Precision, Digits: Integer; ValueType: TFloatValue; Const FormatSettings: TFormatSettings): String;
|
||||||
Var
|
Var
|
||||||
P, PE, Q, Exponent: Integer;
|
P, PE, Q, Exponent: Integer;
|
||||||
@ -1198,17 +1203,17 @@ Begin
|
|||||||
{ First convert to scientific format, with correct precision }
|
{ First convert to scientific format, with correct precision }
|
||||||
case ValueType of
|
case ValueType of
|
||||||
fvDouble:
|
fvDouble:
|
||||||
Str(Double(Extended(Value)):precision+7, Result);
|
Str(Double(Extended(Aligned(Value))):precision+7, Result);
|
||||||
fvSingle:
|
fvSingle:
|
||||||
Str(Single(Extended(Value)):precision+6, Result);
|
Str(Single(Extended(Aligned(Value))):precision+66, Result);
|
||||||
fvCurrency:
|
fvCurrency:
|
||||||
{$ifdef FPC_HAS_STR_CURRENCY}
|
{$ifdef FPC_HAS_STR_CURRENCY}
|
||||||
Str(Currency(Value):precision+6, Result);
|
Str(Currency(Aligned(Value)):precision+6, Result);
|
||||||
{$else}
|
{$else}
|
||||||
Str(Extended(Currency(Value)):precision+8, Result);
|
Str(Extended(Currency(Aligned(Value))):precision+8, Result);
|
||||||
{$endif FPC_HAS_STR_CURRENCY}
|
{$endif FPC_HAS_STR_CURRENCY}
|
||||||
else
|
else
|
||||||
Str(Extended(Value):precision+8, Result);
|
Str(Extended(Aligned(Value)):precision+8, Result);
|
||||||
end;
|
end;
|
||||||
{ Delete leading spaces }
|
{ Delete leading spaces }
|
||||||
while Result[1] = ' ' do
|
while Result[1] = ' ' do
|
||||||
@ -1295,17 +1300,17 @@ Begin
|
|||||||
If (Precision = -1) Or (Precision > maxdigits) Then Precision := maxdigits;
|
If (Precision = -1) Or (Precision > maxdigits) Then Precision := maxdigits;
|
||||||
case ValueType of
|
case ValueType of
|
||||||
fvDouble:
|
fvDouble:
|
||||||
Str(Double(Extended(Value)):Precision+7, Result);
|
Str(Double(Extended(Aligned(Value))):Precision+7, Result);
|
||||||
fvSingle:
|
fvSingle:
|
||||||
Str(Single(Extended(Value)):Precision+6, Result);
|
Str(Single(Extended(Aligned(Value))):Precision+6, Result);
|
||||||
fvCurrency:
|
fvCurrency:
|
||||||
{$ifdef FPC_HAS_STR_CURRENCY}
|
{$ifdef FPC_HAS_STR_CURRENCY}
|
||||||
Str(Currency(Value):Precision+6, Result);
|
Str(Currency(Aligned(Value)):Precision+6, Result);
|
||||||
{$else}
|
{$else}
|
||||||
Str(Extended(Currency(Value)):Precision+8, Result);
|
Str(Extended(Currency(Aligned(Value))):Precision+8, Result);
|
||||||
{$endif FPC_HAS_STR_CURRENCY}
|
{$endif FPC_HAS_STR_CURRENCY}
|
||||||
else
|
else
|
||||||
Str(Extended(Value):Precision+8, Result);
|
Str(Extended(Aligned(Value)):Precision+8, Result);
|
||||||
end;
|
end;
|
||||||
{ Delete leading spaces }
|
{ Delete leading spaces }
|
||||||
while Result[1] = ' ' do
|
while Result[1] = ' ' do
|
||||||
@ -1344,17 +1349,17 @@ Begin
|
|||||||
Else If Digits > 18 Then Digits := 18;
|
Else If Digits > 18 Then Digits := 18;
|
||||||
case ValueType of
|
case ValueType of
|
||||||
fvDouble:
|
fvDouble:
|
||||||
Str(Double(Extended(Value)):0:Digits, Result);
|
Str(Double(Extended(Aligned(Value))):0:Digits, Result);
|
||||||
fvSingle:
|
fvSingle:
|
||||||
Str(Single(Extended(Value)):0:Digits, Result);
|
Str(Single(Extended(Aligned(Value))):0:Digits, Result);
|
||||||
fvCurrency:
|
fvCurrency:
|
||||||
{$ifdef FPC_HAS_STR_CURRENCY}
|
{$ifdef FPC_HAS_STR_CURRENCY}
|
||||||
Str(Currency(Value):0:Digits, Result);
|
Str(Currency(Aligned(Value)):0:Digits, Result);
|
||||||
{$else}
|
{$else}
|
||||||
Str(Extended(Currency(Value)):0:Digits, Result);
|
Str(Extended(Currency(Aligned(Value))):0:Digits, Result);
|
||||||
{$endif FPC_HAS_STR_CURRENCY}
|
{$endif FPC_HAS_STR_CURRENCY}
|
||||||
else
|
else
|
||||||
Str(Extended(Value):0:Digits, Result);
|
Str(Extended(Aligned(Value)):0:Digits, Result);
|
||||||
end;
|
end;
|
||||||
If Result[1] = ' ' Then
|
If Result[1] = ' ' Then
|
||||||
System.Delete(Result, 1, 1);
|
System.Delete(Result, 1, 1);
|
||||||
@ -1369,17 +1374,17 @@ Begin
|
|||||||
Else If Digits > maxdigits Then Digits := maxdigits;
|
Else If Digits > maxdigits Then Digits := maxdigits;
|
||||||
case ValueType of
|
case ValueType of
|
||||||
fvDouble:
|
fvDouble:
|
||||||
Str(Double(Extended(Value)):0:Digits, Result);
|
Str(Double(Extended(Aligned(Value))):0:Digits, Result);
|
||||||
fvSingle:
|
fvSingle:
|
||||||
Str(Single(Extended(Value)):0:Digits, Result);
|
Str(Single(Extended(Aligned(Value))):0:Digits, Result);
|
||||||
fvCurrency:
|
fvCurrency:
|
||||||
{$ifdef FPC_HAS_STR_CURRENCY}
|
{$ifdef FPC_HAS_STR_CURRENCY}
|
||||||
Str(Currency(Value):0:Digits, Result);
|
Str(Currency(Aligned(Value)):0:Digits, Result);
|
||||||
{$else}
|
{$else}
|
||||||
Str(Extended(Currency(Value)):0:Digits, Result);
|
Str(Extended(Currency(Aligned(Value))):0:Digits, Result);
|
||||||
{$endif FPC_HAS_STR_CURRENCY}
|
{$endif FPC_HAS_STR_CURRENCY}
|
||||||
else
|
else
|
||||||
Str(Extended(Value):0:Digits, Result);
|
Str(Extended(Aligned(Value)):0:Digits, Result);
|
||||||
end;
|
end;
|
||||||
If Result[1] = ' ' Then System.Delete(Result, 1, 1);
|
If Result[1] = ' ' Then System.Delete(Result, 1, 1);
|
||||||
P := Pos('.', Result);
|
P := Pos('.', Result);
|
||||||
@ -1403,17 +1408,17 @@ Begin
|
|||||||
Else If Digits > 18 Then Digits := 18;
|
Else If Digits > 18 Then Digits := 18;
|
||||||
case ValueType of
|
case ValueType of
|
||||||
fvDouble:
|
fvDouble:
|
||||||
Str(Double(Extended(Value)):0:Digits, Result);
|
Str(Double(Extended(Aligned(Value))):0:Digits, Result);
|
||||||
fvSingle:
|
fvSingle:
|
||||||
Str(Single(Extended(Value)):0:Digits, Result);
|
Str(Single(Extended(Aligned(Value))):0:Digits, Result);
|
||||||
fvCurrency:
|
fvCurrency:
|
||||||
{$ifdef FPC_HAS_STR_CURRENCY}
|
{$ifdef FPC_HAS_STR_CURRENCY}
|
||||||
Str(Currency(Value):0:Digits, Result);
|
Str(Currency(Aligned(Value)):0:Digits, Result);
|
||||||
{$else}
|
{$else}
|
||||||
Str(Extended(Currency(Value)):0:Digits, Result);
|
Str(Extended(Currency(Aligned(Value))):0:Digits, Result);
|
||||||
{$endif FPC_HAS_STR_CURRENCY}
|
{$endif FPC_HAS_STR_CURRENCY}
|
||||||
else
|
else
|
||||||
Str(Extended(Value):0:Digits, Result);
|
Str(Extended(Aligned(Value)):0:Digits, Result);
|
||||||
end;
|
end;
|
||||||
Negative:=Result[1] = '-';
|
Negative:=Result[1] = '-';
|
||||||
if Negative then
|
if Negative then
|
||||||
@ -1466,7 +1471,7 @@ Begin
|
|||||||
if not (format in [ffCurrency]) and (length(Result) > 1) and (Result[1] = '-') then
|
if not (format in [ffCurrency]) and (length(Result) > 1) and (Result[1] = '-') then
|
||||||
RemoveLeadingNegativeSign(Result);
|
RemoveLeadingNegativeSign(Result);
|
||||||
End;
|
End;
|
||||||
|
{$macro off}
|
||||||
|
|
||||||
{$ifdef FPC_HAS_TYPE_EXTENDED}
|
{$ifdef FPC_HAS_TYPE_EXTENDED}
|
||||||
Function FloatToStr(Value: Extended; Const FormatSettings: TFormatSettings): String;
|
Function FloatToStr(Value: Extended; Const FormatSettings: TFormatSettings): String;
|
||||||
|
Loading…
Reference in New Issue
Block a user