0

AS3:

    public static function testFunction(a:Number, b:String="", c:String=""):String {
    var fmt:NumberFormatter = new NumberFormatter();
    fmt.precision = -1;
    fmt.useThousandsSeparator = false;
    var s:String = fmt.format(a);
    }

How to convert it to Javascript. I'm very confused and I think I need NumberFormatter in JS. Any recommend suggestions?

2
  • please provide your logic also Commented Nov 25, 2015 at 11:12
  • Yes, what are you actually trying to achieve? Commented Nov 25, 2015 at 11:24

1 Answer 1

2

You can set precision like this

 var num = 13.3714;
 var n = num.toPrecision(2);

for more info see http://www.w3schools.com/jsref/jsref_toprecision.asp

also http://openexchangerates.github.io/accounting.js/ and
http://numeraljs.com/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.