Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
Delphi 10.4 Sydney
|
AW: Großen Float-Wert ohne Exponent darstellen?
1. Jun 2015, 10:30
Delphi-Quellcode:
function ExtendedToDecimal(Number: extended): string;
var
FloatRec: TFloatRec;
DecimalSeparatorPosition: integer;
begin
FloatToDecimal(FloatRec, Number, fvExtended, 18, 9999);
Result := FloatRec.Digits;
if Result = '' then
Result := '0'
else
begin
if FloatRec.Exponent > 0 then
Result := Result + StringOfChar(#48, FloatRec.Exponent - Length(Result))
else
if FloatRec.Exponent < 0 then
Result := StringOfChar(#48, -FloatRec.Exponent) + Result;
if FloatRec.Exponent < 0 then
DecimalSeparatorPosition := 1
else
DecimalSeparatorPosition := FloatRec.Exponent + 1;
if DecimalSeparatorPosition <= Length(Result) then
Insert(DecimalSeparator, Result, DecimalSeparatorPosition);
if DecimalSeparatorPosition = 1 then
Result := '0' + Result;
if FloatRec.Negative then
Result := '-' + Result;
end;
end;
|
|
Zitat
|