Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "math/base/special/roundb/docs/types/index.d"

Index

Functions

Functions

Export assignment roundb

  • roundb(x: number, n: number, b: number): number
  • Rounds a numeric value to the nearest multiple of \(b^n\) on a linear scale.

    Notes

    • Due to floating-point rounding error, rounding may not be exact.

    Parameters

    • x: number

      input value

    • n: number

      integer power

    • b: number

      positive integer base

    Returns number

    rounded value

    Example

    // Round a value to 2 decimal places:
    var v = roundb( 3.141592653589793, -2, 10 );
    // returns 3.14

    Example

    // If n = 0 or b = 1, `roundb` behaves like `round`:
    var v = roundb( 3.141592653589793, 0, 2 );
    // returns 3.0

    Example

    // Round a value to the nearest multiple of two:
    var v = roundb( 5.0, 1, 2 );
    // returns 6.0