Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/Other RTL    [ Add a report in this area ]  
Report #:  105408   Status: Open
BcdRoundTo and RoundAt return different result
Project:  Delphi Build #:  16.0.4429.46931
Version:    16.4 Submitted By:   Chee Yang Chau
Report Type:  Basic functionality failure Date Reported:  5/7/2012 1:29:35 AM
Severity:    Serious / Highly visible problem Last Updated: 5/16/2012 11:59:10 PM
Platform:    All platforms Internal Tracking #:   28253
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
In Delphi XE2, the RoundAt function in FmtBcd.pas has marked deprecated:

function RoundAt(const Value: string; Position: SmallInt): string; deprecated 'use BcdRoundTo';

However, some cases fail when replace the RoundAt to BcdRoundTo.

BcdRoundTo seems using Banker rounding but RoundAt is using classic rounding (similar to SimpleRoundTo).
Steps to Reproduce:
Run the following code in Delphi XE2:

-----------
var
  B: TBcd;
  S: string;
begin
  S := '109.885';
  B := BcdRoundTo(StrToBcd(S), -2);
  WriteLn('BcdRoundTo: ', BcdToStr(B));
  WriteLn('RoundAt: ', RoundAt(S, 2));
  Readln;
end.
-----------

The output is:

BcdRoundTo: 109.88
RoundAt: 109.89
Workarounds
None
Attachment
None
Comments

Tomohiro Takahashi at 5/17/2012 7:26:54 PM -
This report was opened with valid Internal Tracking Number.
Thanks.

Server Response from: ETNACODE01