View Issue Details

IDProjectCategoryView StatusLast Update
0038489FPCRTLpublic2021-03-22 14:41
Reporterbrick08 Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformWin64OSWindows 
Product Version3.2.0 
Summary0038489: FormatBCD with DisplayFormat = '0.#' and integer values
Descriptionfunction FormatBCD ( const Format : string; BCD : tBCD ) : FmtBCDStringtype
in unit FmtBCD with Format = '0.#' and BCD as integer value, then result output with thousand separator.
Steps To Reproduceprocedure testFormatBCD;
var
  bcd: TBCD;
  s: String;
begin
  bcd := StrToBCD('0');
  s := FormatBCD('0.#', bcd);
  WriteLn(s);
end;

The result looks like this: '0.'
Correctly it should look like without thousand separator: '0'
TagsFmtBCD
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

LacaK

2021-02-24 14:20

developer   ~0129142

Last edited: 2021-02-24 14:21

View 2 revisions

Possible patch attached + updated unti test
tfmtbcd.pp.diff (307 bytes)   
--- tfmtbcd.pp.ori	Wed Feb 24 14:15:56 2021
+++ tfmtbcd.pp	Wed Feb 24 14:14:37 2021
@@ -253,6 +253,7 @@
   bcd:=strtobcd('0');
   testFormatBCD('0;;0',bcd, '0');
   testFormatBCD('0;;#',bcd, '');
+  testFormatBCD('0;;0.#',bcd, '0');
   testFormatBCD('0;;0.00',bcd, '0.00');
 
   // test StrToBCD:
tfmtbcd.pp.diff (307 bytes)   

LacaK

2021-02-24 14:44

developer   ~0129144

fmtbcd.pp.diff (759 bytes)   
--- fmtbcd.pp.ori	Wed Feb 24 12:39:27 2021
+++ fmtbcd.pp	Wed Feb 24 14:42:44 2021
@@ -2835,10 +2835,12 @@
       PFmt := Section.FmtDS; // start from decimal point until end
       i := length(BCDStr) - Scale + ord(Scale=0);
       dec(j1, Section.FmtEnd-Section.FmtDS);
-      j := j1 + 1;
+      j := j1 + 1; // points to decimal separator in output buffer
       while PFmt < Section.FmtEnd do
         PutFmtDigit(PFmt, i, j, 1);
-      je := j; // store position after last decimal digit
+      if j-j1=2 then // alone decimal separator at end of output buffer
+        dec(j);
+      je := j; // store position after last decimal digit (or any constant character) in output buffer
     end;
 
     // output whole number part of BCDStr
fmtbcd.pp.diff (759 bytes)   

Issue History

Date Modified Username Field Change
2021-02-15 11:54 brick08 New Issue
2021-02-24 14:20 LacaK Note Added: 0129142
2021-02-24 14:20 LacaK File Added: fmtbcd.pp.diff
2021-02-24 14:20 LacaK File Added: tfmtbcd.pp.diff
2021-02-24 14:21 LacaK Note Edited: 0129142 View Revisions
2021-02-24 14:27 LacaK File Deleted: fmtbcd.pp.diff
2021-02-24 14:44 LacaK File Deleted: fmtbcd.pp.diff
2021-02-24 14:44 LacaK Note Added: 0129144
2021-02-24 14:44 LacaK File Added: fmtbcd.pp.diff
2021-03-22 14:41 LacaK Tag Attached: FmtBCD