phaser - v4.0.0-rc.4
    Preparing search index...

    Function RoundTo

    • Round a value to the given precision.

      For example:

      RoundTo(123.456, 0) = 123
      RoundTo(123.456, 1) = 120
      RoundTo(123.456, 2) = 100

      To round the decimal, i.e. to round to precision, pass in a negative place:

      RoundTo(123.456789, 0) = 123
      RoundTo(123.456789, -1) = 123.5
      RoundTo(123.456789, -2) = 123.46
      RoundTo(123.456789, -3) = 123.457

      Parameters

      • value: number

        The value to round.

      • Optionalplace: number

        The place to round to. Positive to round the units, negative to round the decimal. Default 0.

      • Optionalbase: number

        The base to round in. Default is 10 for decimal. Default 10.

      Returns number