diff --git a/lib/node_modules/@stdlib/math/base/special/roundb/README.md b/lib/node_modules/@stdlib/math/base/special/roundb/README.md index ef9a104be6ec..2342fdaa8139 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundb/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundb/README.md @@ -102,6 +102,80 @@ for ( i = 0; i < 100; i++ ) { + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/roundb.h" +``` + +#### stdlib_base_roundb( x, n, b ) + +Rounds a `numeric` value to the nearest multiple of `b^n` on a linear scale. + +```c +double out = stdlib_base_roundb( 3.141592653589793, -2, 10 ); +// returns 3.14 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **n**: `[in] int32_t` power. +- **b**: `[in] int32_t` base. + +```c +double stdlib_base_roundb( const double x, const int32_t n, const int32_t b ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/roundb.h" +#include +#include + +int main( void ) { + const double x[] = { -5.0, -3.89, -2.78, -1.67, -0.56, 0.56, 1.67, 2.78, 3.89, 5.0 }; + const int32_t n[] = { -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 }; + const int32_t b[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11 }; + + double v; + int i; + for ( i = 0; i < 10; i++ ) { + v = stdlib_base_roundb( x[ i ], n[ i ], b[ i ] ); + printf( "roundb(%lf, %d, %d) = %lf\n", x[ i ], n[ i ], b[ i ], v ); + } +} +``` + +
+ + + + + + +