About 51 results
Open links in new tab
  1. JavaScript math, round to two decimal places - Stack Overflow

    I have the following JavaScript syntax: var discount = Math.round(100 - (price / listprice) * 100); This rounds up to the whole number. How can I return the result with two decimal places?

  2. javascript - How to round to at most 2 decimal places, if necessary ...

    I'd like to round at most two decimal places, but only if necessary. Input: 10 1.7777777 9.1 Output: 10 1.78 9.1 How can I do this in JavaScript?

  3. Format number to always show 2 decimal places - Stack Overflow

    May 26, 2011 · Round the number with 2 decimal points, then make sure to parse it with parseFloat() to return Number, not String unless you don't care if it is String or Number.

  4. Formatting a number with exactly two decimals in JavaScript

    Nov 13, 2009 · alert(precise_round('1.27499999999999993', 2)); Note that this function rounds to nearest, ties away from zero, while IEEE 754 recommends rounding to nearest, ties to even as …

  5. jquery - round value to 2 decimals javascript - Stack Overflow

    var priceString = someValue.toFixed(2); The answer by @David has two problems: It leaves the result as a floating point number, and consequently holds the possibility of displaying a …

  6. Javascript: formatting a rounded number to N decimals

    It returns a string, not a number. So it doesn't round a number to N decimals, it creates a string that humans can read as a number with decimals. But ony if they, by accident, use the same …

  7. javascript - How do I round to 2 decimal places? - Stack Overflow

    Nov 22, 2011 · I have a number with a comma, for example: 254,5. I need the 0 behind the ,5 so it stands like 254,50 instead.. I'm using this to get the number: Math.floor(iAlt / 50) * 50; How can …

  8. javascript - How to round down number 2 decimal places? - Stack …

    The 3 methods you propose are rounding the decimals up. But the question was how to round them down. toFixed is rounding them down.

  9. javascript - Redondear a dos decimales cuando sea necesario

    Me gustaría redondear a dos decimales, sólo cuando sea necesario. A continuación ejemplos de entradas y salidas Entrada: 10 1.7777777 9.1 Salida: 10 1.78 9.1 ¿Cómo puedo hacer esto en …

  10. JavaScript displaying a float to 2 decimal places

    Jul 2, 2010 · Note that this will round to a maximum of 3 decimal places, just like the round() function suggested above in the default case. If you want to customize that behavior to specify …