You've already forked lazarus-ccr
fpspreadsheet: Fix error in Round function. Add a second unit test for Round.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6217 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -315,7 +315,7 @@ begin
|
|||||||
n := Args[1].ResInteger
|
n := Args[1].ResInteger
|
||||||
else
|
else
|
||||||
n := round(Args[1].ResFloat);
|
n := round(Args[1].ResFloat);
|
||||||
Result := FloatResult(RoundTo(ArgToFloat(Args[0]), n));
|
Result := FloatResult(RoundTo(ArgToFloat(Args[0]), -n));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure fpsSIGN(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsSIGN(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
|
@ -2963,6 +2963,7 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
nf: TsNumberFormat;
|
nf: TsNumberFormat;
|
||||||
nfs: String;
|
nfs: String;
|
||||||
decs: Byte;
|
decs: Byte;
|
||||||
|
sint: String;
|
||||||
s: String;
|
s: String;
|
||||||
f: Double;
|
f: Double;
|
||||||
fracInt, fracNum, fracDenom: Integer;
|
fracInt, fracNum, fracDenom: Integer;
|
||||||
@ -2986,6 +2987,9 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
end else
|
end else
|
||||||
if nodeName = 'number:number' then
|
if nodeName = 'number:number' then
|
||||||
begin
|
begin
|
||||||
|
sint := GetAttrValue(node, 'number:min-integer-digits');
|
||||||
|
if sint = '' then sint := '1';
|
||||||
|
|
||||||
s := GetAttrValue(node, 'number:decimal-places');
|
s := GetAttrValue(node, 'number:decimal-places');
|
||||||
if s = '' then
|
if s = '' then
|
||||||
s := GetAttrValue(node, 'decimal-places');
|
s := GetAttrValue(node, 'decimal-places');
|
||||||
@ -3000,7 +3004,7 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
s := GetAttrValue(node, 'number:display-factor');
|
s := GetAttrValue(node, 'number:display-factor');
|
||||||
if s <> '' then f := StrToFloat(s, FPointSeparatorSettings) else f := 1.0;
|
if s <> '' then f := StrToFloat(s, FPointSeparatorSettings) else f := 1.0;
|
||||||
nf := IfThen(grouping, nfFixedTh, nfFixed);
|
nf := IfThen(grouping, nfFixedTh, nfFixed);
|
||||||
nfs := nfs + BuildNumberFormatString(nf, Workbook.FormatSettings, decs);
|
nfs := nfs + BuildNumberFormatString(nf, Workbook.FormatSettings, decs); //, StrToInt(sint));
|
||||||
if f <> 1.0 then begin
|
if f <> 1.0 then begin
|
||||||
nf := nfCustom;
|
nf := nfCustom;
|
||||||
while (f > 1.0) do
|
while (f > 1.0) do
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="10"/>
|
<Version Value="11"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
@ -57,9 +57,10 @@
|
|||||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<FormatVersion Value="2"/>
|
||||||
<FormatVersion Value="1"/>
|
<Modes Count="1">
|
||||||
</local>
|
<Mode0 Name="default"/>
|
||||||
|
</Modes>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="1">
|
<RequiredPackages Count="1">
|
||||||
<Item1>
|
<Item1>
|
||||||
@ -176,7 +177,7 @@
|
|||||||
<Filename Value="spreadtestcli"/>
|
<Filename Value="spreadtestcli"/>
|
||||||
</Target>
|
</Target>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="..\source;$(ProjOutDir)"/>
|
||||||
<OtherUnitFiles Value="..\source\common;..\source\visual;..\source\export"/>
|
<OtherUnitFiles Value="..\source\common;..\source\visual;..\source\export"/>
|
||||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
@ -187,7 +188,7 @@
|
|||||||
</Linking>
|
</Linking>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<Exceptions Count="5">
|
<Exceptions Count="6">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Name Value="ECodetoolError"/>
|
<Name Value="ECodetoolError"/>
|
||||||
<Enabled Value="False"/>
|
<Enabled Value="False"/>
|
||||||
@ -198,7 +199,6 @@
|
|||||||
</Item2>
|
</Item2>
|
||||||
<Item3>
|
<Item3>
|
||||||
<Name Value="EAssertionFailedError"/>
|
<Name Value="EAssertionFailedError"/>
|
||||||
<Enabled Value="False"/>
|
|
||||||
</Item3>
|
</Item3>
|
||||||
<Item4>
|
<Item4>
|
||||||
<Name Value="Exception"/>
|
<Name Value="Exception"/>
|
||||||
@ -208,6 +208,9 @@
|
|||||||
<Name Value="EIBDatabaseError"/>
|
<Name Value="EIBDatabaseError"/>
|
||||||
<Enabled Value="False"/>
|
<Enabled Value="False"/>
|
||||||
</Item5>
|
</Item5>
|
||||||
|
<Item6>
|
||||||
|
<Name Value="EIgnoredTest"/>
|
||||||
|
</Item6>
|
||||||
</Exceptions>
|
</Exceptions>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
@ -1586,9 +1586,26 @@
|
|||||||
RPNFunc('ROUND', nil)))))
|
RPNFunc('ROUND', nil)))))
|
||||||
else
|
else
|
||||||
myWorksheet.WriteFormula(Row, 1, formula);
|
myWorksheet.WriteFormula(Row, 1, formula);
|
||||||
myWorksheet.WriteNumber(Row, 2, RoundTo(pi, 2));
|
// NOTE: Excel and FPS have different signs in number of digits
|
||||||
|
myWorksheet.WriteNumber(Row, 2, RoundTo(pi, -2));
|
||||||
SetLength(sollValues, Row+1);
|
SetLength(sollValues, Row+1);
|
||||||
sollValues[Row] := FloatResult(RoundTo(pi, 2));
|
sollValues[Row] := FloatResult(RoundTo(pi, -2));
|
||||||
|
|
||||||
|
// ROUND
|
||||||
|
inc(Row);
|
||||||
|
formula := 'ROUND(12345.6789,-2)';
|
||||||
|
MyWorksheet.WriteUTF8Text(Row, 0, formula);
|
||||||
|
if UseRPNFormula then
|
||||||
|
MyWorksheet.WriteRPNFormula(Row, 1, CreateRPNFormula(
|
||||||
|
RPNNumber(12345.6789,
|
||||||
|
RPNNumber(-2,
|
||||||
|
RPNFunc('ROUND', nil)))))
|
||||||
|
else
|
||||||
|
myWorksheet.WriteFormula(Row, 1, formula);
|
||||||
|
// NOTE: Excel and FPS have different signs in number of digits
|
||||||
|
myWorksheet.WriteNumber(Row, 2, RoundTo(12345.6789, 2));
|
||||||
|
SetLength(sollValues, Row+1);
|
||||||
|
sollValues[Row] := FloatResult(RoundTo(12345.6789, 2));
|
||||||
|
|
||||||
// SIGN
|
// SIGN
|
||||||
inc(Row);
|
inc(Row);
|
||||||
|
Reference in New Issue
Block a user