4 Replies Latest reply on Jul 13, 2011 7:53 AM by jfb00

    decimal formatter issue

    jfb00 Level 3

      Hi All,

      In a datagrid I use labelFunction method to format input numbers, this function will format decimal numbers with precision 2.

      public static function formatDecimal(val:Number):String
              {
                  var decimalFormatter: NumberFormatter = new NumberFormatter();
                  decimalFormatter.rounding = "up";
                  decimalFormatter.precision = 2;
                  decimalFormatter.useNegativeSign = false;
                  return decimalFormatter.format(val);
              }
      

      Now, if the input is 2.55 only, it format the number to 2.56. It is a way to prevent this?

      It should format 2.56 if the input is 2.555. correct?

      Thanks

       

      JFB