Do not cut trailing zeros in scientific values like 2.0e30 => 2.0e3. Closes #1793

This commit is contained in:
Ansgar Becker
2023-04-07 10:32:49 +02:00
parent d9d1f26278
commit 2a28d39b3e

View File

@ -10134,7 +10134,7 @@ end;
procedure TMainForm.AnyGridGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; procedure TMainForm.AnyGridGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string); Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
var var
EditingAndFocused: Boolean; EditingAndFocused, IsScientific: Boolean;
RowNumber: PInt64; RowNumber: PInt64;
Results: TDBQuery; Results: TDBQuery;
Timestamp: Int64; Timestamp: Int64;
@ -10178,10 +10178,12 @@ begin
end else begin end else begin
CellText := Results.Col(Column); CellText := Results.Col(Column);
// Keep only wanted trailing zeros directly after decimal separator // Keep only wanted number of trailing zeros after decimal separator
// Bug fixed: Do not cut trailing zeros in scientific values like 2.0e30 => 2.0e3
if (Results.DataType(Column).Category = dtcReal) and (AppSettings.ReadInt(asRealTrailingZeros) >= 0) then begin if (Results.DataType(Column).Category = dtcReal) and (AppSettings.ReadInt(asRealTrailingZeros) >= 0) then begin
DotPos := Pos('.', CellText); DotPos := Pos('.', CellText);
if DotPos > 0 then begin IsScientific := ContainsText(CellText, 'e');
if (not IsScientific) and (DotPos > 0) then begin
NumZeros := 0; NumZeros := 0;
NumDecimals := 0; NumDecimals := 0;
for i:=DotPos+1 to Length(CellText) do begin for i:=DotPos+1 to Length(CellText) do begin