Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
Delphi 12 Athens
|
Re: Max. 3 Nachkommastellen
15. Jun 2009, 10:40
OK, hatte ich zwar noch nicht das Problem, aber dann einfach so ^^
Delphi-Quellcode:
Function MyFormat(f: Extended; Precession: Byte; Width: Byte = 0): String;
Begin
Result := Format('%*.*n', [Width, Precession, f]);
If Pos(DecimalSeparator, Result) > 0 Then Begin
While Result[Length(Result)] = '0' do Delete(Result, Length(Result), 1);
If Result[Length(Result)] = DecimalSeparator Then Delete(Result, Length(Result), 1);
End;
End;
oder
Delphi-Quellcode:
Function MyFormat(f: Extended; Precession: Byte; Width: Byte = 0): String;
Var i: Integer;
Begin
Result := Format(' %*.*n', [Width, Precession, f]);
If Pos(DecimalSeparator, Result) > 0 Then Begin
i := Length(Result);
While Result[i] = ' 0' do Dec Dec(i);
If Result[i] = DecimalSeparator Then Dec(i);
Result := Copy(Result, 1, i);
End;
End;
$2B or not $2B
|
|
Zitat
|