MyFaces Trinidad
  1. MyFaces Trinidad
  2. TRINIDAD-2139

Client NumberConverter with type=percent ignores maxfractiondigits when formatting

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-core
    • Fix Version/s: 2.0.1-core
    • Component/s: Components
    • Labels:
      None

      Description

      NumberFormat.js contains the following code:
      TrNumberFormat.prototype.percentageToString = function(number)

      { number = number * 100; number = this.getRounded(number); .. number = this.numberToString(number); }

      consideration the number of fractionDigits but numberToString later will.
      TrNumberFormat.prototype.getRounded = function(val)

      { val = this.moveDecimalRight(val); val = Math.round(val); val = this.moveDecimalLeft(val); return val; }

      Math.round function will round to the nearest integer. With the earlier multiplication to 100, precision is preserved to at most two digits, regardless of the maxFractionDigits attribute.

        Activity

        Hide
        Yee-Wah Lee added a comment -

        The Math.round code appears to have been there since the numberConverter was first created, it appears to be an overlooked when later fixes were made for maxFractionDigits.

        The getRounded call can be removed, since numberToString will take into account min/maxFractionDigits.

        Show
        Yee-Wah Lee added a comment - The Math.round code appears to have been there since the numberConverter was first created, it appears to be an overlooked when later fixes were made for maxFractionDigits. The getRounded call can be removed, since numberToString will take into account min/maxFractionDigits.
        Hide
        Yee-Wah Lee added a comment - - edited

        Trinidad-2139 patch for trunk and 1.2.12.6.0 branch

        Show
        Yee-Wah Lee added a comment - - edited Trinidad-2139 patch for trunk and 1.2.12.6.0 branch
        Hide
        Yee-Wah Lee added a comment -

        Updated patch to retain previous behavior if maxFractionDigits is not set.

        Show
        Yee-Wah Lee added a comment - Updated patch to retain previous behavior if maxFractionDigits is not set.
        Hide
        Scott O'Bryan added a comment -

        This issue is now closed

        Show
        Scott O'Bryan added a comment - This issue is now closed
        Hide
        Yee-Wah Lee added a comment - - edited

        1.2.12.7.0 fix for Trinidad-2139, allow NumberFormat to honor maxFractionDigits

        Patch also works for 1.2.12.6.2 branch

        Show
        Yee-Wah Lee added a comment - - edited 1.2.12.7.0 fix for Trinidad-2139, allow NumberFormat to honor maxFractionDigits Patch also works for 1.2.12.6.2 branch

          People

          • Assignee:
            Gabrielle Crawford
            Reporter:
            Yee-Wah Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development