melonJS
    Preparing search index...

    Function round

    • round a value to the specified number of digit. Rounds to the nearest value, and a tie the way Math.round does, toward positive infinity: round(2.5) is 3 and round(-2.5) is -2.

      Parameters

      • num: number

        value to be rounded.

      • Optionaldec: number = 0

        number of decimal digit to be rounded to.

      Returns number

      rounded value

      // round a specific value to 2 digits
      math.round(10.33333, 2); // return 10.33
      math.round(-2.7); // return -3