Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/Format + Float    [ Add a report in this area ]  
Report #:  102074   Status: Closed
[Regression in XE2] FormatBcd() formats incorrectly
Project:  Delphi Build #:  16.0.4358.45540
Version:    16.3 Submitted By:   Jose Luis Rocha
Report Type:  Basic functionality failure Date Reported:  12/23/2011 2:26:20 PM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   289275
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: 9
Description
FormatBcd incorrectly returns a extra dot character with '0.##' mask and numbers without decimals.

ej.:

FormatBcd('0.##', 1.0) output: '1.' (with a final dot)

This bug affects to the DisplayFormat of TBcdFields and TFmtBcdFields.

//USc: This is regression from XE.
Steps to Reproduce:
By USc:
- dcc QC102074.dpr
- execute QC102074

expected: output is PASS
actual:
FAIL #1 Expected: "1" Actual: "1."
FAIL

program QC102074;

{$APPTYPE CONSOLE}

uses
  SysUtils, FMTBcd;

var
  Counter: Integer;
  S: string;
  Bcd: TBcd;
begin
  FormatSettings.DecimalSeparator := '.';//make test #2 pass on non US systems
  Counter := 0;

  Bcd := DoubleToBcd(1.0);
  S := FormatBcd('0.##', Bcd);
  if S = '1' then
    Inc(Counter)
  else
    WriteLn('FAIL #1 Expected: "1" Actual: "', S, '"');

  Bcd := DoubleToBcd(1.23);
  S := FormatBcd('0.##', Bcd);
  if S = '1.23' then
    Inc(Counter)
  else
    WriteLn('FAIL #2 Expected: "1.23" Actual: "', S, '"');

  if Counter = 2 then
    WriteLn('PASS')
  else
    WriteLn('FAIL');
end.



Original steps:
procedure TForm1.Button1Click(Sender: TObject);
begin

  ShowMessage(FormatFloat('0.##', 1.0));    // output: '1'

  ShowMessage(FormatCurr('0.##', 1.0));     // output: '1'

  ShowMessage(FormatBcd('0.##', 1.0));     // output: '1.' (with dot)

end;
Workarounds
None
Attachment
None
Comments

Tomohiro Takahashi at 12/24/2011 4:50:58 AM -
Is this a regression in XE2 (Update 3)?
What about previous versions of Delphi?

Lars Meyer at 12/24/2011 8:39:23 AM -
Update#2 has the same behavior.

Jose Luis Rocha at 3/7/2012 12:21:14 PM -
Fixed in Upd 4.

Tomohiro Takahashi at 3/7/2012 5:25:13 PM -
Thanks for the confirmation.
yes, this issue is fixed in Update 4.
http://edn.embarcadero.com/article/42090

Server Response from: ETNACODE01