diff --git a/math/base/special/cceiln/coverage.ndjson b/math/base/special/cceiln/coverage.ndjson new file mode 100644 index 000000000..ad13bbd54 --- /dev/null +++ b/math/base/special/cceiln/coverage.ndjson @@ -0,0 +1 @@ +[266,266,100,5,5,100,2,2,100,266,266,100,"141b0fd0b248ea0d68e126fb2d6920080000833a","2023-09-23 12:17:25 -0700"] diff --git a/math/base/special/cceiln/index.html b/math/base/special/cceiln/index.html new file mode 100644 index 000000000..7c408fbeb --- /dev/null +++ b/math/base/special/cceiln/index.html @@ -0,0 +1,146 @@ + + + + +
++ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
index.js | +
+
+ |
+ 100% | +82/82 | +100% | +1/1 | +100% | +0/0 | +100% | +82/82 | +
main.js | +
+
+ |
+ 100% | +92/92 | +100% | +2/2 | +100% | +1/1 | +100% | +92/92 | +
native.js | +
+
+ |
+ 100% | +92/92 | +100% | +2/2 | +100% | +1/1 | +100% | +92/92 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Round each component of a double-precision floating-point complex number to the nearest multiple of `10^n` toward positive infinity. +* +* @module @stdlib/math/base/special/cceiln +* +* @example +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* var cceiln = require( '@stdlib/math/base/special/cceiln' ); +* +* // Round components to 2 decimal places: +* var z = new Complex128( -3.141592653589793, 3.141592653589793 ) +* var v = cceiln( z, -2 ); +* // returns <Complex128> +* +* var re = real( v ); +* // returns -3.14 +* +* var im = imag( v ); +* // returns 3.15 +* +* // If n = 0, `cceiln` behaves like `cceil`: +* z = new Complex128( 9.99999, 0.1 ) +* v = cceiln( z, 0 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns 10.0 +* +* im = imag( v ); +* // returns 1.0 +* +* // Round components to the nearest thousand: +* z = new Complex128( 12368.0, -12368.0 ) +* v = cceiln( z, 3 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns 13000.0 +* +* im = imag( v ); +* // returns -12000.0 +* +* v = cceiln( new Complex128( NaN, NaN ), 2 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns NaN +* +* im = imag( v ); +* // returns NaN +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +444x +444x +444x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var ceiln = require( '@stdlib/math/base/special/ceiln' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + + +// MAIN // + +/** +* Rounds each component of a double-precision complex floating-point number to the nearest multiple of `10^n` toward positive infinity. +* +* @param {Complex128} z - complex number +* @param {integer} n - integer power of 10 +* @returns {Complex128} result +* +* @example +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* // Round components to 2 decimal places: +* var z = new Complex128( -3.141592653589793, 3.141592653589793 ) +* var v = cceiln( z, -2 ); +* // returns <Complex128> +* +* var re = real( v ); +* // returns -3.14 +* +* var im = imag( v ); +* // returns 3.15 +* +* // If n = 0, `cceiln` behaves like `cceil`: +* z = new Complex128( 9.99999, 0.1 ) +* v = cceiln( z, 0 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns 10.0 +* +* im = imag( v ); +* // returns 1.0 +* +* // Round components to the nearest thousand: +* z = new Complex128( 12368.0, -12368.0 ) +* v = cceiln( z, 3 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns 13000.0 +* +* im = imag( v ); +* // returns -12000.0 +* +* v = cceiln( new Complex128( NaN, NaN ), 2 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns NaN +* +* im = imag( v ); +* // returns NaN +*/ +function cceiln( z, n ) { + return new Complex128( ceiln( real( z ), n ), ceiln( imag( z ), n ) ); +} + + +// EXPORTS // + +module.exports = cceiln; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +441x +441x +441x +441x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Complex128 = require( '@stdlib/complex/float64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Rounds each component of a double-precision complex floating-point number to the nearest multiple of `10^n` toward positive infinity. +* +* @private +* @param {Complex128} z - complex number +* @param {integer} n - integer power of 10 +* @returns {Complex128} result +* +* @example +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* // Round components to 2 decimal places: +* var z = new Complex128( -3.141592653589793, 3.141592653589793 ) +* var v = cceiln( z, -2 ); +* // returns <Complex128> +* +* var re = real( v ); +* // returns -3.14 +* +* var im = imag( v ); +* // returns 3.15 +* +* // If n = 0, `cceiln` behaves like `cceil`: +* z = new Complex128( 9.99999, 0.1 ) +* v = cceiln( z, 0 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns 10.0 +* +* im = imag( v ); +* // returns 1.0 +* +* // Round components to the nearest thousand: +* z = new Complex128( 12368.0, -12368.0 ) +* v = cceiln( z, 3 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns 13000.0 +* +* im = imag( v ); +* // returns -12000.0 +* +* v = cceiln( new Complex128( NaN, NaN ), 2 ); +* // returns <Complex128> +* +* re = real( v ); +* // returns NaN +* +* im = imag( v ); +* // returns NaN +*/ +function cceiln( z, n ) { + var v = addon( z, n ); + return new Complex128( v.re, v.im ); +} + + +// EXPORTS // + +module.exports = cceiln; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
index.js | +
+
+ |
+ 100% | +49/49 | +100% | +1/1 | +100% | +0/0 | +100% | +49/49 | +
main.js | +
+
+ |
+ 100% | +165/165 | +100% | +21/21 | +100% | +1/1 | +100% | +165/165 | +
native.js | +
+
+ |
+ 100% | +58/58 | +100% | +2/2 | +100% | +1/1 | +100% | +58/58 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Round a numeric value to the nearest multiple of `10^n` toward positive infinity. +* +* @module @stdlib/math/base/special/ceiln +* +* @example +* var ceiln = require( '@stdlib/math/base/special/ceiln' ); +* +* // Round a value to 2 decimal places: +* var v = ceiln( 3.141592653589793, -2 ); +* // returns 3.15 +* +* // If n = 0, `ceiln` behaves like `ceil`: +* v = ceiln( 3.141592653589793, 0 ); +* // returns 4.0 +* +* // Round a value to the nearest thousand: +* v = ceiln( 12368.0, 3 ); +* // returns 13000.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +448x +448x +448x +448x +448x +448x +445x +448x +5x +5x +443x +443x +448x +441x +441x +448x +434x +434x +448x +334x +334x +334x +448x +209x +209x +234x +448x +200x +100x +100x +100x +100x +34x +448x +18x +18x +18x +2x +2x +16x +16x +16x +16x +448x +2x +2x +14x +448x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isInfinite = require( '@stdlib/math/base/assert/is-infinite' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var ceil = require( '@stdlib/math/base/special/ceil' ); +var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); +var MAX_EXP = require( '@stdlib/constants/float64/max-base10-exponent' ); +var MIN_EXP = require( '@stdlib/constants/float64/min-base10-exponent' ); +var MIN_EXP_SUBNORMAL = require( '@stdlib/constants/float64/min-base10-exponent-subnormal' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); + + +// VARIABLES // + +var MAX_INT = MAX_SAFE_INTEGER + 1; +var HUGE = 1.0e+308; + + +// MAIN // + +/** +* Rounds a numeric value to the nearest multiple of \\(10^n\\) toward positive infinity. +* +* ## Method +* +* 1. If \\(|x| <= 2^{53}\\) and \\(|n| <= 308\\), we can use the formula +* +* ```tex +* \operatorname{ceiln}(x,n) = \frac{\operatorname{ceil}(x \cdot 10^{-n})}{10^{-n}} +* ``` +* +* which shifts the decimal to the nearest multiple of \\(10^n\\), performs a standard \\(\mathrm{ceil}\\) operation, and then shifts the decimal to its original position. +* +* <!-- <note> --> +* +* If \\(x \cdot 10^{-n}\\) overflows, \\(x\\) lacks a sufficient number of decimal digits to have any effect when rounding. Accordingly, the rounded value is \\(x\\). +* +* <!-- </note> --> +* +* <!-- <note> --> +* +* Note that rescaling \\(x\\) can result in unexpected behavior. For instance, the result of \\(\operatorname{ceiln}(0.2+0.1,-16)\\) is \\(0.3000000000000001\\) and not \\(0.3\\). While possibly unexpected, this is not a bug. The behavior stems from the fact that most decimal fractions cannot be exactly represented as floating-point numbers. And further, rescaling can lead to slightly different fractional values, which, in turn, affects the result of \\(\mathrm{ceil}\\). +* +* <!-- </note> --> +* +* 2. If \\(n > 308\\), we recognize that the maximum absolute double-precision floating-point number is \\(\approx 1.8\mbox{e}308\\) and, thus, the result of rounding any possible positive finite number \\(x\\) to the nearest \\(10^n\\) is \\(\infty\\) and any possible negative finite number \\(x\\) is \\(-0\\). To ensure consistent behavior with \\(\operatorname{ceil}(x)\\), if \\(x < 0\\), the sign of \\(x\\) is preserved. +* +* 3. If \\(n < -324\\), \\(n\\) exceeds the maximum number of possible decimal places (such as with subnormal numbers), and, thus, the rounded value is \\(x\\). +* +* 4. If \\(x > 2^{53}\\), \\(x\\) is **always** an integer (i.e., \\(x\\) has no decimal digits). If \\(n <= 0\\), the rounded value is \\(x\\). +* +* 5. If \\(n < -308\\), we let \\(m = n + 308\\) and modify the above formula to avoid overflow. +* +* ```tex +* \operatorname{ceiln}(x,n) = \frac{\biggl(\frac{\operatorname{ceil}( (x \cdot 10^{308}) 10^{-m})}{10^{308}}\biggr)}{10^{-m}} +* ``` +* +* If overflow occurs, the rounded value is \\(x\\). +* +* ## Special Cases +* +* ```tex +* \begin{align*} +* \operatorname{ceiln}(\mathrm{NaN}, n) &= \mathrm{NaN} \\ +* \operatorname{ceiln}(x, \mathrm{NaN}) &= \mathrm{NaN} \\ +* \operatorname{ceiln}(x, \pm\infty) &= \mathrm{NaN} \\ +* \operatorname{ceiln}(\pm\infty, n) &= \pm\infty \\ +* \operatorname{ceiln}(\pm 0, n) &= \pm 0 +* \end{align*} +* ``` +* +* @param {number} x - input value +* @param {integer} n - integer power of 10 +* @returns {number} rounded value +* +* @example +* // Round a value to 2 decimal places: +* var v = ceiln( 3.141592653589793, -2 ); +* // returns 3.15 +* +* @example +* // If n = 0, `ceiln` behaves like `ceil`: +* var v = ceiln( 3.141592653589793, 0 ); +* // returns 4.0 +* +* @example +* // Round a value to the nearest thousand: +* var v = ceiln( 12368.0, 3 ); +* // returns 13000.0 +*/ +function ceiln( x, n ) { + var s; + var y; + if ( + isnan( x ) || + isnan( n ) || + isInfinite( n ) + ) { + return NaN; + } + if ( + // Handle infinities... + isInfinite( x ) || + + // Handle +-0... + x === 0.0 || + + // If `n` exceeds the maximum number of feasible decimal places (such as with subnormal numbers), nothing to round... + n < MIN_EXP_SUBNORMAL || + + // If `|x|` is large enough, no decimals to round... + ( abs( x ) > MAX_INT && n <= 0 ) + ) { + return x; + } + // The maximum absolute double is ~1.8e308. Accordingly, any possible positive finite `x` rounded to the nearest >=10^309 is infinity and any negative finite `x` is zero. + if ( n > MAX_EXP ) { + if ( x <= 0.0 ) { + return -0.0; // preserve the sign (same behavior as ceil) + } + return PINF; + } + // If we overflow, return `x`, as the number of digits to the right of the decimal is too small (i.e., `x` is too large / lacks sufficient fractional precision) for there to be any effect when rounding... + if ( n < MIN_EXP ) { + s = pow( 10.0, -(n + MAX_EXP) ); + y = (x*HUGE) * s; // order of operation matters! + if ( isInfinite( y ) ) { + return x; + } + return ( ceil(y)/HUGE ) / s; + } + s = pow( 10.0, -n ); + y = x * s; + if ( isInfinite( y ) ) { + return x; + } + return ceil( y ) / s; +} + + +// EXPORTS // + +module.exports = ceiln; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +444x +444x +444x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2023 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Rounds a double-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity. +* +* @private +* @param {number} x - input value +* @param {integer} n - integer power of 10 +* @returns {number} rounded value +* +* @example +* // Round a value to 2 decimal places: +* var v = ceiln( 3.141592653589793, -2 ); +* // returns 3.15 +* +* @example +* // If n = 0, `ceiln` behaves like `ceil`: +* var v = ceiln( 3.141592653589793, 0 ); +* // returns 4.0 +* +* @example +* // Round a value to the nearest thousand: +* var v = ceiln( 12368.0, 3 ); +* // returns 13000.0 +*/ +function ceiln( x, n ) { + return addon( x, n ); +} + + +// EXPORTS // + +module.exports = ceiln; + |