• Function to round a number to the nearest power of a specified base.

    Parameters

    • x: DecimalSource

      The number to round.

    • base: DecimalSource = 10

      The power base to round to. Defaults to 10. Must be greater than 1 (can be fractional, although not recommended).

    • acc: DecimalSource = 0

      The accuracy / significant figures to round to. Defaults to 0. Must be greater than 1.

    • max: DecimalSource = 1000

      The maximum power to round to. Defaults to 1000. If x > base^max, x is returned.

    Returns Decimal

    roundingBase(123456789, 10); // 100000000
    roundingBase(123456789, 10, 1); // 120000000
    roundingBase(123456789, 10, 2); // 123000000
    roundingBase(245, 2); // 256