Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/Other RTL    [ Add a report in this area ]  
Report #:  103106   Status: Closed
[REGRESSION in XE2] BcdDivide(1, 3) returns Bcd value of up to 64 decimal places
Project:  Delphi Build #:  16.0.4358.45540
Version:    16.3 Submitted By:   Chee Yang Chau
Report Type:  Crash / Data loss / Total failure Date Reported:  2/2/2012 5:44:24 AM
Severity:    Serious / Highly visible problem Last Updated: 12/19/2012 7:59:59 PM
Platform:    All platforms Internal Tracking #:   289755
Resolution: Fixed (Resolution Comments) Resolved in Build: : Update 4
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Running the following code in Delphi XE2 console apps:

var A, B, C, D: TBcd;
begin
  A := StrToBcd('1');
  B := StrToBcd('3');
  BcdDivide(A, B, C);
  WriteLn(BcdToStr(C));

  try
    BcdMultiply(C, C, D);
    WriteLn(BcdToStr(D));
  except
    on E: Exception do
      WriteLn(E.Message);
  end;

  ReadLn;
end.

The output will be:

0.333333333333333333333333333333333333333333333333333333333333333
BCD overflow

The variable C contains a Bcd Value with decimal places of 63.  Perform further BcdMultiply operation on variable C will cause Bcd overflow error.

However, running the same code in Delphi XE yields the following result without any exception prompt:

0.3333333333
0.11111111108888888889

Steps to Reproduce:
None
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01