You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jing Wu (JIRA)" <de...@myfaces.apache.org> on 2011/01/26 22:44:43 UTC

[jira] Created: (TRINIDAD-2021) Wrong behavior in TrNumberFormat

Wrong behavior in TrNumberFormat
--------------------------------

                 Key: TRINIDAD-2021
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2021
             Project: MyFaces Trinidad
          Issue Type: Bug
          Components: Components
    Affects Versions: 1.2.13-core 
         Environment: Environment independent.
            Reporter: Jing Wu
            Priority: Minor


Currently implementation of formatting a fraction part of a number is shown below: when maxFra is the same as minFra, and facsLength is larger than maxFra, the number will not be formatted correctly.

TrNumberFormat.prototype._formatFractions = function(fracs)
{
  var fracsLength = fracs.length;
  var maxFra = this.getMaximumFractionDigits();
  var minFra = this.getMinimumFractionDigits();

  if(fracsLength > maxFra && maxFra>minFra)
  {
    fracs = fracs.substring(0, maxFra);
  }
  if(fracsLength <minFra)
  {
    var gap = minFra-fracsLength;
    
    //we need to add some zeros
    while(gap>0)
    {
      fracs = fracs + "0";
      --gap;
    }
  }
  return fracs;
}

The 7th line of the above code should be:

  if(fracsLength > maxFra && maxFra >= minFra)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (TRINIDAD-2021) Wrong behavior in TrNumberFormat

Posted by "Jing Wu (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/TRINIDAD-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Wu resolved TRINIDAD-2021.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2.15-core 

issue is fixed.

> Wrong behavior in TrNumberFormat
> --------------------------------
>
>                 Key: TRINIDAD-2021
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2021
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.2.13-core 
>         Environment: Environment independent.
>            Reporter: Jing Wu
>            Priority: Minor
>             Fix For: 1.2.15-core 
>
>         Attachments: numberformat.patch
>
>
> Currently implementation of formatting a fraction part of a number is shown below: when maxFra is the same as minFra, and facsLength is larger than maxFra, the number will not be formatted correctly.
> TrNumberFormat.prototype._formatFractions = function(fracs)
> {
>   var fracsLength = fracs.length;
>   var maxFra = this.getMaximumFractionDigits();
>   var minFra = this.getMinimumFractionDigits();
>   if(fracsLength > maxFra && maxFra>minFra)
>   {
>     fracs = fracs.substring(0, maxFra);
>   }
>   if(fracsLength <minFra)
>   {
>     var gap = minFra-fracsLength;
>     
>     //we need to add some zeros
>     while(gap>0)
>     {
>       fracs = fracs + "0";
>       --gap;
>     }
>   }
>   return fracs;
> }
> The 7th line of the above code should be:
>   if(fracsLength > maxFra && maxFra >= minFra)

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (TRINIDAD-2021) Wrong behavior in TrNumberFormat

Posted by "Jing Wu (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12989353#comment-12989353 ] 

Jing Wu commented on TRINIDAD-2021:
-----------------------------------

to see the problem, run the following script in your browser debug console window:

var numFormat = TrNumberFormat.getNumberInstance(null);
numFormat.setMaximumFractionDigits(3);
numFormat.setMinimumFractionDigits(3);
numFormat.format("1.1234");

It will return "1.1234" instead of "1.123".

> Wrong behavior in TrNumberFormat
> --------------------------------
>
>                 Key: TRINIDAD-2021
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2021
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.2.13-core 
>         Environment: Environment independent.
>            Reporter: Jing Wu
>            Priority: Minor
>         Attachments: numberformat.patch
>
>
> Currently implementation of formatting a fraction part of a number is shown below: when maxFra is the same as minFra, and facsLength is larger than maxFra, the number will not be formatted correctly.
> TrNumberFormat.prototype._formatFractions = function(fracs)
> {
>   var fracsLength = fracs.length;
>   var maxFra = this.getMaximumFractionDigits();
>   var minFra = this.getMinimumFractionDigits();
>   if(fracsLength > maxFra && maxFra>minFra)
>   {
>     fracs = fracs.substring(0, maxFra);
>   }
>   if(fracsLength <minFra)
>   {
>     var gap = minFra-fracsLength;
>     
>     //we need to add some zeros
>     while(gap>0)
>     {
>       fracs = fracs + "0";
>       --gap;
>     }
>   }
>   return fracs;
> }
> The 7th line of the above code should be:
>   if(fracsLength > maxFra && maxFra >= minFra)

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira