wvmoreira / jquery-numberformatter

Automatically exported from code.google.com/p/jquery-numberformatter
0 stars 0 forks source link

Percent: rounding error #48

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
JavaScript
    $("#testPercent").blur(function(){
        //alert($(this).val()+' -- '+$(this).parseNumber({format:"#.##%", locale:"us"}));   
        $(this).parseNumber({format:"#.##%", locale:"us"});     
        $(this).formatNumber({format:"#.##%", locale:"us"});
    });

    $("#testPercent1").blur(function(){ 
        $(this).parseNumber({format:"#.00%", locale:"us"});     
        $(this).formatNumber({format:"#.00%", locale:"us"});
    });
HTML
        <table border="0">
            <tbody>
                <tr>
                    <td>Field 4. On blur formats %</td>
                    <td><input id="testPercent" type="text" tabindex="1" />
                    </td>
                    <td>Format: "#.##%" Locale: "us"</td>
                </tr>
                <tr>
                    <td>Field 5. On blur formats %</td>
                    <td><input id="testPercent1" type="text" tabindex="1" />
                    </td>
                    <td>Format: "#.00%" Locale: "us"</td>
                </tr>                               
            </tbody>
        </table>
2. When a value with two decimals and percentage sign is entered, the last 
digit is lost
3. Entered: 3.33%

What is the expected output? What do you see instead?
Expected: 3.33% Result: 3.3% in the first field and 3.30% in the second field

What version of the product are you using? On what operating system?
1.2.2 jQuery 1.6.2

Please provide any additional information below.

Original issue reported on code.google.com by discover...@gmail.com on 24 Aug 2011 at 7:16

GoogleCodeExporter commented 8 years ago
This is a duplicate of another issue. The solution is on line 441, for some 
reason there's a "-1" which is subtracting the number of significant digits by 
one.

Original comment by darwinca...@gmail.com on 29 Aug 2011 at 5:16

GoogleCodeExporter commented 8 years ago
Thanks both, will be looking into it for the next release.

Original comment by apar...@gmail.com on 11 Sep 2011 at 4:36

GoogleCodeExporter commented 8 years ago
Yes I think this is duplicate. Now fixed.

Original comment by apar...@gmail.com on 5 Feb 2012 at 1:38