Wrong rounding in RB14.xx
In RB 12.xx following function "Test" returns a correct result, which is 42.73.
However with RB14.xx and RB15.xx the result is 42 which is imho wrong.
The problem seems to be that the multiplication of an int64 value with
an double value results in an int64 and not in a double value!
function Test: double;
var
lFactor : double;
lResult : double;
lTestValue : double;
begin
lFactor := IntPower(10, -2);
lTestValue := 42.7342;
lResult := Trunc(lTestValue / lFactor) * lFactor;
{ WRONG: lResult should be 42.73 not 42!! }
Result := lResult;
end;
A workaround is to assign the result of the Trunc-Function to an intermediate
double variable.
function TestOK: double;
var
lFactor : double;
lResult : double;
lTestValue : double;
lTemp : double;
begin
lFactor := IntPower(10, -2);
lTestValue := 42.7342;
lTemp := Trunc(lTestValue / lFactor);
lResult := lTemp * lFactor;
{ lResult is OK: 42.73 }
Result := lResult;
end;
We have a lot of reports doing such calculations and we cannot modify all
reports to implement the workaround (aside from the problem to find all
possible wrong calculations)
Please provide us with a fix for this problem.
Our current RB Version in production use is RB14.08.
Regards
Frank
However with RB14.xx and RB15.xx the result is 42 which is imho wrong.
The problem seems to be that the multiplication of an int64 value with
an double value results in an int64 and not in a double value!
function Test: double;
var
lFactor : double;
lResult : double;
lTestValue : double;
begin
lFactor := IntPower(10, -2);
lTestValue := 42.7342;
lResult := Trunc(lTestValue / lFactor) * lFactor;
{ WRONG: lResult should be 42.73 not 42!! }
Result := lResult;
end;
A workaround is to assign the result of the Trunc-Function to an intermediate
double variable.
function TestOK: double;
var
lFactor : double;
lResult : double;
lTestValue : double;
lTemp : double;
begin
lFactor := IntPower(10, -2);
lTestValue := 42.7342;
lTemp := Trunc(lTestValue / lFactor);
lResult := lTemp * lFactor;
{ lResult is OK: 42.73 }
Result := lResult;
end;
We have a lot of reports doing such calculations and we cannot modify all
reports to implement the workaround (aside from the problem to find all
possible wrong calculations)
Please provide us with a fix for this problem.
Our current RB Version in production use is RB14.08.
Regards
Frank
This discussion has been closed.
Comments
There is a patch available for RB 15 Build 2 that solves this issue. If
you would like the patch, please send an email to
support@digital-metaphors.com with your Delphi version included.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
last Friday I send an email to support@digital-metaphors.com to request the
patch. Until now I did not get a response...?
Are there any problems with the patch on your side?
We need a patch for ReportBuilder 14.08 and Delphi 2010, because this
combination is in use by our customers.
Thanks for any help to solve the problem promptly.
Regards
Frank