Numbers and delimiters added to a numeric string incorrectly

Created on 16 July 2020, over 4 years ago
Updated 10 March 2023, over 1 year ago

Problem/motivation:

At its current state, `src/Plugin/Field/FieldFormatter/BigIntItemDefaultFormatter.php` returns incorrect values under certain conditions.

The method numberFormat processes the string as follows:

  1. Obtains three characters, starting from the end of a numeric string
  2. Stores the obtained characters in the above step in an array
  3. Removes the obtained characters from the original numeric string in the variable
  4. Repeats 1~3 until the entire string is processed
  5. Restores the numeric string from the characters stored in the array, with the specified delimiter

The problem lies in the steps #2 and 3. When the length of the numeric string is either two, or the remainder is 2 when the length is divided by 3, the formatter places the first character and the delimiter at the beginning of the string.

Examples:

  • 10 => 110 or 1,10
  • 10000 => 110000 or 1,10,000
  • 10000000 => 110000000 or 1,10,000,000

Proposed resolution

Apply the patch to correct the formatting issue without making changes to the functionality of the numberFormat method itself.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands dokumori Utrecht

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024