E
E
eldar_web2015-11-06 14:13:43
JavaScript
eldar_web, 2015-11-06 14:13:43

How to round a fractional number to two decimal places in JS?

For example, we calculate like this: And the result can be like this: 1456.914819423 How to round this number two two zeros after the decimal points?
var summ = toFloat(212,31) * toFloat(723,62);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2015-11-06
@eldar_web

+12.3456789.toFixed(2); //12.35

// можно сделать удобную функцию 
function fix (num, n) {
    return +num.toFixed(n);
}

fix(12.3456789, 2); // 12.35

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question