Opened 8 years ago

Closed 8 years ago

#14526 closed defect (fixed)

wxNumberFormatter::AddThousandsSeparators() doesn't account for a sign at the beginning of the string s

Reported by: PB Owned by:
Priority: normal Milestone:
Component: base Version: stable-latest
Keywords: Cc: pbfordev@…
Blocked By: Blocking:
Patch: no


wxNumberFormatter::AddThousandsSeparators(wxString& s) doesn't account for a possible sign at the beginning of the string s.

For example

s = wxNumberFormatter::ToString((long)-123); // s = "-,123" 
s = wxNumberFormatter::ToString((long)-123456); // s = "-,123,456"

As the class is obviously only for numbers and not monetary values, it wouldn't be wrong to assume that the sign is always "-" at the beginning of the string or none, would be?

Change History (2)

comment:1 Changed 8 years ago by vadz

  • Status changed from new to confirmed

Thanks, I see the bug, will check in a fix soon.

comment:2 Changed 8 years ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [72256]) Fix bug in wxNumberFormatter::ToString() for negative numbers.

Don't include the possible leading sign in the span of digits to be grouped as
this gave nonsensical strings such as "-,123" when adding thousands separators
to "123".

Closes #14526.

Note: See TracTickets for help on using tickets.