@stdlib/math-base-special-ceiln 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
package/LICENSE CHANGED
@@ -175,307 +175,3 @@
175
175
  of your accepting any such warranty or additional liability.
176
176
 
177
177
  END OF TERMS AND CONDITIONS
178
-
179
-
180
-
181
- Boost Software License - Version 1.0 - August 17th, 2003
182
-
183
- Permission is hereby granted, free of charge, to any person or organization
184
- obtaining a copy of the software and accompanying documentation covered by this
185
- license (the "Software") to use, reproduce, display, distribute, execute, and
186
- transmit the Software, and to prepare derivative works of the Software, and to
187
- permit third-parties to whom the Software is furnished to do so, all subject to
188
- the following:
189
-
190
- The copyright notices in the Software and this entire statement, including the
191
- above license grant, this restriction and the following disclaimer, must be
192
- included in all copies of the Software, in whole or in part, and all derivative
193
- works of the Software, unless such copies or derivative works are solely in the
194
- form of machine-executable object code generated by a source language processor.
195
-
196
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
197
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
198
- FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
199
- COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
200
- OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
201
- OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
202
-
203
-
204
-
205
-
206
- DEPENDENCIES
207
-
208
- The library links against the following external libraries, which have their own
209
- licenses:
210
-
211
- * OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
212
- def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
213
-
214
- Copyright (c) 2011-2014, The OpenBLAS Project
215
- All rights reserved.
216
-
217
- Redistribution and use in source and binary forms, with or without
218
- modification, are permitted provided that the following conditions are
219
- met:
220
-
221
- 1. Redistributions of source code must retain the above copyright
222
- notice, this list of conditions and the following disclaimer.
223
-
224
- 2. Redistributions in binary form must reproduce the above copyright
225
- notice, this list of conditions and the following disclaimer in
226
- the documentation and/or other materials provided with the
227
- distribution.
228
-
229
- 3. Neither the name of the OpenBLAS project nor the names of
230
- its contributors may be used to endorse or promote products
231
- derived from this software without specific prior written
232
- permission.
233
-
234
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
235
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
237
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
238
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
239
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
240
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
242
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
243
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
244
-
245
-
246
- * Electron <https://raw.githubusercontent.com/electron/electron/
247
- c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
248
-
249
- Copyright (c) 2013-2017 GitHub Inc.
250
-
251
- Permission is hereby granted, free of charge, to any person obtaining
252
- a copy of this software and associated documentation files (the
253
- "Software"), to deal in the Software without restriction, including
254
- without limitation the rights to use, copy, modify, merge, publish,
255
- distribute, sublicense, and/or sell copies of the Software, and to
256
- permit persons to whom the Software is furnished to do so, subject to
257
- the following conditions:
258
-
259
- The above copyright notice and this permission notice shall be
260
- included in all copies or substantial portions of the Software.
261
-
262
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
263
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
264
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
265
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
266
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
267
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
268
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
269
-
270
-
271
- * Boost <http://www.boost.org/LICENSE_1_0.txt>
272
-
273
- Boost Software License - Version 1.0 - August 17th, 2003
274
-
275
- Permission is hereby granted, free of charge, to any person or organization
276
- obtaining a copy of the software and accompanying documentation covered by
277
- this license (the "Software") to use, reproduce, display, distribute,
278
- execute, and transmit the Software, and to prepare derivative works of the
279
- Software, and to permit third-parties to whom the Software is furnished to
280
- do so, all subject to the following:
281
-
282
- The copyright notices in the Software and this entire statement, including
283
- the above license grant, this restriction and the following disclaimer,
284
- must be included in all copies of the Software, in whole or in part, and
285
- all derivative works of the Software, unless such copies or derivative
286
- works are solely in the form of machine-executable object code generated by
287
- a source language processor.
288
-
289
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
290
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
291
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
292
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
293
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
294
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
295
- DEALINGS IN THE SOFTWARE.
296
-
297
-
298
- * Cephes <http://www.netlib.org/cephes/readme>
299
-
300
- Copyright (c) 1984-2000 Stephen L. Moshier
301
-
302
- Some software in this archive may be from the book _Methods and Programs for
303
- Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
304
- or from the Cephes Mathematical Library, a commercial product. In either event,
305
- it is copyrighted by the author. What you see here may be used freely but it
306
- comes with no support or guarantee.
307
-
308
- Stephen L. Moshier
309
- moshier@na-net.ornl.gov
310
-
311
-
312
-
313
- ATTRIBUTION
314
-
315
- The library contains implementations from the following external libraries,
316
- which have their own licenses:
317
-
318
- * FreeBSD <https://svnweb.freebsd.org/>
319
-
320
- Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
321
-
322
- Developed at SunPro, a Sun Microsystems, Inc. business.
323
- Permission to use, copy, modify, and distribute this
324
- software is freely granted, provided that this notice
325
- is preserved.
326
-
327
-
328
- * FDLIBM <http://www.netlib.org/fdlibm/>
329
-
330
- Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
331
-
332
- Developed at SunPro, a Sun Microsystems, Inc. business.
333
- Permission to use, copy, modify, and distribute this
334
- software is freely granted, provided that this notice
335
- is preserved.
336
-
337
-
338
- * Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
339
-
340
- Copyright (c) 2009 The Go Authors. All rights reserved.
341
-
342
- Redistribution and use in source and binary forms, with or without
343
- modification, are permitted provided that the following conditions are
344
- met:
345
-
346
- * Redistributions of source code must retain the above copyright
347
- notice, this list of conditions and the following disclaimer.
348
- * Redistributions in binary form must reproduce the above
349
- copyright notice, this list of conditions and the following disclaimer
350
- in the documentation and/or other materials provided with the
351
- distribution.
352
- * Neither the name of Google Inc. nor the names of its
353
- contributors may be used to endorse or promote products derived from
354
- this software without specific prior written permission.
355
-
356
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
357
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
358
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
359
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
360
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
361
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
362
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
363
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
364
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
366
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
367
-
368
-
369
- * SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
370
-
371
- Public domain.
372
-
373
-
374
- * ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
375
-
376
- Copyright JS Foundation and other contributors, https://js.foundation
377
-
378
- Permission is hereby granted, free of charge, to any person obtaining a copy
379
- of this software and associated documentation files (the "Software"), to deal
380
- in the Software without restriction, including without limitation the rights
381
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
382
- copies of the Software, and to permit persons to whom the Software is
383
- furnished to do so, subject to the following conditions:
384
-
385
- The above copyright notice and this permission notice shall be included in
386
- all copies or substantial portions of the Software.
387
-
388
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
389
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
390
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
391
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
392
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
393
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
394
- THE SOFTWARE.
395
-
396
-
397
- * StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
398
- e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
399
-
400
- Copyright (c) 2015: Dahua Lin.
401
-
402
- Permission is hereby granted, free of charge, to any person obtaining
403
- a copy of this software and associated documentation files (the
404
- "Software"), to deal in the Software without restriction, including
405
- without limitation the rights to use, copy, modify, merge, publish,
406
- distribute, sublicense, and/or sell copies of the Software, and to
407
- permit persons to whom the Software is furnished to do so, subject to
408
- the following conditions:
409
-
410
- The above copyright notice and this permission notice shall be
411
- included in all copies or substantial portions of the Software.
412
-
413
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
414
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
415
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
416
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
417
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
418
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
419
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
420
-
421
-
422
- * SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
423
- SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
424
-
425
- The MIT License (MIT)
426
-
427
- Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
428
-
429
- https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
430
-
431
- Permission is hereby granted, free of charge, to any person obtaining a copy
432
- of this software and associated documentation files (the "Software"), to deal
433
- in the Software without restriction, including without limitation the rights
434
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
435
- copies of the Software, and to permit persons to whom the Software is
436
- furnished to do so, subject to the following conditions:
437
-
438
- The above copyright notice and this permission notice shall be included in all
439
- copies or substantial portions of the Software.
440
-
441
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
442
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
443
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
444
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
445
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
446
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
447
- SOFTWARE.
448
-
449
-
450
- * MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
451
- mt19937ar.c>
452
-
453
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
454
- All rights reserved.
455
-
456
- Redistribution and use in source and binary forms, with or without
457
- modification, are permitted provided that the following conditions
458
- are met:
459
-
460
- 1. Redistributions of source code must retain the above copyright
461
- notice, this list of conditions and the following disclaimer.
462
-
463
- 2. Redistributions in binary form must reproduce the above copyright
464
- notice, this list of conditions and the following disclaimer in the
465
- documentation and/or other materials provided with the distribution.
466
-
467
- 3. The names of its contributors may not be used to endorse or promote
468
- products derived from this software without specific prior written
469
- permission.
470
-
471
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
472
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
473
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
474
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
475
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
476
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
477
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
478
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
479
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
480
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
481
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 The Stdlib Authors.
package/README.md CHANGED
@@ -18,6 +18,17 @@ limitations under the License.
18
18
 
19
19
  -->
20
20
 
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
21
32
  # ceiln
22
33
 
23
34
  [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
@@ -110,6 +121,101 @@ for ( i = 0; i < 100; i++ ) {
110
121
 
111
122
  <!-- /.examples -->
112
123
 
124
+ <!-- C interface documentation. -->
125
+
126
+ * * *
127
+
128
+ <section class="c">
129
+
130
+ ## C APIs
131
+
132
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
133
+
134
+ <section class="intro">
135
+
136
+ </section>
137
+
138
+ <!-- /.intro -->
139
+
140
+ <!-- C usage documentation. -->
141
+
142
+ <section class="usage">
143
+
144
+ ### Usage
145
+
146
+ ```c
147
+ #include "stdlib/math/base/special/ceiln.h"
148
+ ```
149
+
150
+ #### stdlib_base_ceiln( x, n )
151
+
152
+ Rounds a double-precision floating-point number to the nearest multiple of `10^n` toward positive infinity.
153
+
154
+ ```c
155
+ // Round a value to 2 decimal places:
156
+ double y = stdlib_base_ceiln( 3.141592653589793, -2 );
157
+ // returns 3.15
158
+
159
+ // If n = 0, `ceiln` behaves like `ceil`:
160
+ double y = stdlib_base_ceiln( 3.141592653589793, 0 );
161
+ // returns 4.0
162
+
163
+ // Round a value to the nearest thousand:
164
+ double y = stdlib_base_ceiln( 12368.0, 3 );
165
+ // returns 13000.0
166
+ ```
167
+
168
+ The function accepts the following arguments:
169
+
170
+ - **x**: `[in] double` input value.
171
+ - **n**: `[in] int32_t` integer power of 10.
172
+
173
+ ```c
174
+ double stdlib_base_ceiln( const double x, const int32_t n );
175
+ ```
176
+
177
+ </section>
178
+
179
+ <!-- /.usage -->
180
+
181
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
182
+
183
+ <section class="notes">
184
+
185
+ </section>
186
+
187
+ <!-- /.notes -->
188
+
189
+ <!-- C API usage examples. -->
190
+
191
+ <section class="examples">
192
+
193
+ ### Examples
194
+
195
+ ```c
196
+ #include "stdlib/math/base/special/ceiln.h"
197
+ #include <stdio.h>
198
+
199
+ int main() {
200
+ const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 };
201
+
202
+ double y;
203
+ int i;
204
+ for ( i = 0; i < 4; i++ ) {
205
+ y = stdlib_base_ceiln( x[ i ], -2 );
206
+ printf( "ceiln(%lf, -2) = %lf\n", x[ i ], y );
207
+ }
208
+ }
209
+ ```
210
+
211
+ </section>
212
+
213
+ <!-- /.examples -->
214
+
215
+ </section>
216
+
217
+ <!-- /.c -->
218
+
113
219
  <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
114
220
 
115
221
  <section class="related">
@@ -118,10 +224,10 @@ for ( i = 0; i < 100; i++ ) {
118
224
 
119
225
  ## See Also
120
226
 
121
- - <span class="package-name">[`@stdlib/math/base/special/ceil`][@stdlib/math/base/special/ceil]</span><span class="delimiter">: </span><span class="description">round a double-precision floating-point number toward positive infinity.</span>
122
- - <span class="package-name">[`@stdlib/math/base/special/ceilb`][@stdlib/math/base/special/ceilb]</span><span class="delimiter">: </span><span class="description">round a numeric value to the nearest multiple of b^n toward positive infinity.</span>
123
- - <span class="package-name">[`@stdlib/math/base/special/floorn`][@stdlib/math/base/special/floorn]</span><span class="delimiter">: </span><span class="description">round a numeric value to the nearest multiple of 10^n toward negative infinity.</span>
124
- - <span class="package-name">[`@stdlib/math/base/special/roundn`][@stdlib/math/base/special/roundn]</span><span class="delimiter">: </span><span class="description">round a numeric value to the nearest multiple of 10^n.</span>
227
+ - <span class="package-name">[`@stdlib/math-base/special/ceil`][@stdlib/math/base/special/ceil]</span><span class="delimiter">: </span><span class="description">round a double-precision floating-point number toward positive infinity.</span>
228
+ - <span class="package-name">[`@stdlib/math-base/special/ceilb`][@stdlib/math/base/special/ceilb]</span><span class="delimiter">: </span><span class="description">round a numeric value to the nearest multiple of b^n toward positive infinity.</span>
229
+ - <span class="package-name">[`@stdlib/math-base/special/floorn`][@stdlib/math/base/special/floorn]</span><span class="delimiter">: </span><span class="description">round a numeric value to the nearest multiple of 10^n toward negative infinity.</span>
230
+ - <span class="package-name">[`@stdlib/math-base/special/roundn`][@stdlib/math/base/special/roundn]</span><span class="delimiter">: </span><span class="description">round a numeric value to the nearest multiple of 10^n.</span>
125
231
 
126
232
  </section>
127
233
 
@@ -153,7 +259,7 @@ See [LICENSE][stdlib-license].
153
259
 
154
260
  ## Copyright
155
261
 
156
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
262
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
157
263
 
158
264
  </section>
159
265
 
@@ -166,8 +272,8 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
166
272
  [npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-special-ceiln.svg
167
273
  [npm-url]: https://npmjs.org/package/@stdlib/math-base-special-ceiln
168
274
 
169
- [test-image]: https://github.com/stdlib-js/math-base-special-ceiln/actions/workflows/test.yml/badge.svg
170
- [test-url]: https://github.com/stdlib-js/math-base-special-ceiln/actions/workflows/test.yml
275
+ [test-image]: https://github.com/stdlib-js/math-base-special-ceiln/actions/workflows/test.yml/badge.svg?branch=v0.1.0
276
+ [test-url]: https://github.com/stdlib-js/math-base-special-ceiln/actions/workflows/test.yml?query=branch:v0.1.0
171
277
 
172
278
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-special-ceiln/main.svg
173
279
  [coverage-url]: https://codecov.io/github/stdlib-js/math-base-special-ceiln?branch=main
@@ -179,19 +285,20 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
179
285
 
180
286
  -->
181
287
 
288
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
289
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
290
+
291
+ [stdlib]: https://github.com/stdlib-js/stdlib
292
+
293
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
294
+
182
295
  [umd]: https://github.com/umdjs/umd
183
296
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
184
297
 
185
298
  [deno-url]: https://github.com/stdlib-js/math-base-special-ceiln/tree/deno
186
299
  [umd-url]: https://github.com/stdlib-js/math-base-special-ceiln/tree/umd
187
300
  [esm-url]: https://github.com/stdlib-js/math-base-special-ceiln/tree/esm
188
-
189
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
190
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
191
-
192
- [stdlib]: https://github.com/stdlib-js/stdlib
193
-
194
- [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
301
+ [branches-url]: https://github.com/stdlib-js/math-base-special-ceiln/blob/main/branches.md
195
302
 
196
303
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/math-base-special-ceiln/main/LICENSE
197
304
 
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import ceiln from '../docs/types/index';
3
+ export = ceiln;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var E=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var N=E(function(l,n){
2
+ var t=require('@stdlib/math-base-assert-is-nan/dist'),a=require('@stdlib/math-base-assert-is-infinite/dist'),v=require('@stdlib/math-base-special-pow/dist'),_=require('@stdlib/math-base-special-abs/dist'),q=require('@stdlib/math-base-special-ceil/dist'),I=require('@stdlib/constants-float64-max-safe-integer/dist'),s=require('@stdlib/constants-float64-max-base10-exponent/dist'),M=require('@stdlib/constants-float64-min-base10-exponent/dist'),X=require('@stdlib/constants-float64-min-base10-exponent-subnormal/dist'),c=require('@stdlib/constants-float64-pinf/dist'),A=I+1,f=1e308;function o(e,r){var i,u;return t(e)||t(r)||a(r)?NaN:a(e)||e===0||r<X||_(e)>A&&r<=0?e:r>s?e<=0?-0:c:r<M?(i=v(10,-(r+s)),u=e*f*i,a(u)?e:q(u)/f/i):(i=v(10,-r),u=e*i,a(u)?e:q(u)/i)}n.exports=o
3
+ });var P=N();module.exports=P;
4
+ /** @license Apache-2.0 */
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar isInfinite = require( '@stdlib/math-base-assert-is-infinite' );\nvar pow = require( '@stdlib/math-base-special-pow' );\nvar abs = require( '@stdlib/math-base-special-abs' );\nvar ceil = require( '@stdlib/math-base-special-ceil' );\nvar MAX_SAFE_INTEGER = require( '@stdlib/constants-float64-max-safe-integer' );\nvar MAX_EXP = require( '@stdlib/constants-float64-max-base10-exponent' );\nvar MIN_EXP = require( '@stdlib/constants-float64-min-base10-exponent' );\nvar MIN_EXP_SUBNORMAL = require( '@stdlib/constants-float64-min-base10-exponent-subnormal' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\n\n\n// VARIABLES //\n\nvar MAX_INT = MAX_SAFE_INTEGER + 1;\nvar HUGE = 1.0e+308;\n\n\n// MAIN //\n\n/**\n* Rounds a numeric value to the nearest multiple of \\\\(10^n\\\\) toward positive infinity.\n*\n* ## Method\n*\n* 1. If \\\\(|x| <= 2^{53}\\\\) and \\\\(|n| <= 308\\\\), we can use the formula\n*\n* ```tex\n* \\operatorname{ceiln}(x,n) = \\frac{\\operatorname{ceil}(x \\cdot 10^{-n})}{10^{-n}}\n* ```\n*\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.\n*\n* <!-- <note> -->\n*\n* 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\\\\).\n*\n* <!-- </note> -->\n*\n* <!-- <note> -->\n*\n* 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}\\\\).\n*\n* <!-- </note> -->\n*\n* 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.\n*\n* 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\\\\).\n*\n* 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\\\\).\n*\n* 5. If \\\\(n < -308\\\\), we let \\\\(m = n + 308\\\\) and modify the above formula to avoid overflow.\n*\n* ```tex\n* \\operatorname{ceiln}(x,n) = \\frac{\\biggl(\\frac{\\operatorname{ceil}( (x \\cdot 10^{308}) 10^{-m})}{10^{308}}\\biggr)}{10^{-m}}\n* ```\n*\n* If overflow occurs, the rounded value is \\\\(x\\\\).\n*\n* ## Special Cases\n*\n* ```tex\n* \\begin{align*}\n* \\operatorname{ceiln}(\\mathrm{NaN}, n) &= \\mathrm{NaN} \\\\\n* \\operatorname{ceiln}(x, \\mathrm{NaN}) &= \\mathrm{NaN} \\\\\n* \\operatorname{ceiln}(x, \\pm\\infty) &= \\mathrm{NaN} \\\\\n* \\operatorname{ceiln}(\\pm\\infty, n) &= \\pm\\infty \\\\\n* \\operatorname{ceiln}(\\pm 0, n) &= \\pm 0\n* \\end{align*}\n* ```\n*\n* @param {number} x - input value\n* @param {integer} n - integer power of 10\n* @returns {number} rounded value\n*\n* @example\n* // Round a value to 2 decimal places:\n* var v = ceiln( 3.141592653589793, -2 );\n* // returns 3.15\n*\n* @example\n* // If n = 0, `ceiln` behaves like `ceil`:\n* var v = ceiln( 3.141592653589793, 0 );\n* // returns 4.0\n*\n* @example\n* // Round a value to the nearest thousand:\n* var v = ceiln( 12368.0, 3 );\n* // returns 13000.0\n*/\nfunction ceiln( x, n ) {\n\tvar s;\n\tvar y;\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( n ) ||\n\t\tisInfinite( n )\n\t) {\n\t\treturn NaN;\n\t}\n\tif (\n\t\t// Handle infinities...\n\t\tisInfinite( x ) ||\n\n\t\t// Handle +-0...\n\t\tx === 0.0 ||\n\n\t\t// If `n` exceeds the maximum number of feasible decimal places (such as with subnormal numbers), nothing to round...\n\t\tn < MIN_EXP_SUBNORMAL ||\n\n\t\t// If `|x|` is large enough, no decimals to round...\n\t\t( abs( x ) > MAX_INT && n <= 0 )\n\t) {\n\t\treturn x;\n\t}\n\t// 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.\n\tif ( n > MAX_EXP ) {\n\t\tif ( x <= 0.0 ) {\n\t\t\treturn -0.0; // preserve the sign (same behavior as ceil)\n\t\t}\n\t\treturn PINF;\n\t}\n\t// 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...\n\tif ( n < MIN_EXP ) {\n\t\ts = pow( 10.0, -(n + MAX_EXP) );\n\t\ty = (x*HUGE) * s; // order of operation matters!\n\t\tif ( isInfinite( y ) ) {\n\t\t\treturn x;\n\t\t}\n\t\treturn ( ceil(y)/HUGE ) / s;\n\t}\n\ts = pow( 10.0, -n );\n\ty = x * s;\n\tif ( isInfinite( y ) ) {\n\t\treturn x;\n\t}\n\treturn ceil( y ) / s;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ceiln;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Round a numeric value to the nearest multiple of `10^n` toward positive infinity.\n*\n* @module @stdlib/math-base-special-ceiln\n*\n* @example\n* var ceiln = require( '@stdlib/math-base-special-ceiln' );\n*\n* // Round a value to 2 decimal places:\n* var v = ceiln( 3.141592653589793, -2 );\n* // returns 3.15\n*\n* // If n = 0, `ceiln` behaves like `ceil`:\n* v = ceiln( 3.141592653589793, 0 );\n* // returns 4.0\n*\n* // Round a value to the nearest thousand:\n* v = ceiln( 12368.0, 3 );\n* // returns 13000.0\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAa,QAAS,sCAAuC,EAC7DC,EAAM,QAAS,+BAAgC,EAC/CC,EAAM,QAAS,+BAAgC,EAC/CC,EAAO,QAAS,gCAAiC,EACjDC,EAAmB,QAAS,4CAA6C,EACzEC,EAAU,QAAS,+CAAgD,EACnEC,EAAU,QAAS,+CAAgD,EACnEC,EAAoB,QAAS,yDAA0D,EACvFC,EAAO,QAAS,gCAAiC,EAKjDC,EAAUL,EAAmB,EAC7BM,EAAO,MA2EX,SAASC,EAAOC,EAAGC,EAAI,CACtB,IAAIC,EACAC,EACJ,OACChB,EAAOa,CAAE,GACTb,EAAOc,CAAE,GACTb,EAAYa,CAAE,EAEP,IAIPb,EAAYY,CAAE,GAGdA,IAAM,GAGNC,EAAIN,GAGFL,EAAKU,CAAE,EAAIH,GAAWI,GAAK,EAEtBD,EAGHC,EAAIR,EACHO,GAAK,EACF,GAEDJ,EAGHK,EAAIP,GACRQ,EAAIb,EAAK,GAAM,EAAEY,EAAIR,EAAS,EAC9BU,EAAKH,EAAEF,EAAQI,EACVd,EAAYe,CAAE,EACXH,EAECT,EAAKY,CAAC,EAAEL,EAASI,IAE3BA,EAAIb,EAAK,GAAM,CAACY,CAAE,EAClBE,EAAIH,EAAIE,EACHd,EAAYe,CAAE,EACXH,EAEDT,EAAMY,CAAE,EAAID,EACpB,CAKAhB,EAAO,QAAUa,ICzHjB,IAAIK,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "isInfinite", "pow", "abs", "ceil", "MAX_SAFE_INTEGER", "MAX_EXP", "MIN_EXP", "MIN_EXP_SUBNORMAL", "PINF", "MAX_INT", "HUGE", "ceiln", "x", "n", "s", "y", "main"]
7
+ }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /**
22
22
  * Rounds a numeric value to the nearest multiple of `10^n` toward positive infinity.
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2023 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include <stdint.h>
20
+
21
+ /**
22
+ * Header file containing function declarations.
23
+ */
24
+ #ifndef STDLIB_MATH_BASE_SPECIAL_CEILN_H
25
+ #define STDLIB_MATH_BASE_SPECIAL_CEILN_H
26
+
27
+ /*
28
+ * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
29
+ */
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+
34
+ /**
35
+ * Rounds a double-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity.
36
+ */
37
+ double stdlib_base_ceiln( const double x, const int32_t n );
38
+
39
+ #ifdef __cplusplus
40
+ }
41
+ #endif
42
+
43
+ #endif // !STDLIB_MATH_BASE_SPECIAL_CEILN_H
package/include.gypi ADDED
@@ -0,0 +1,53 @@
1
+ # @license Apache-2.0
2
+ #
3
+ # Copyright (c) 2023 The Stdlib Authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # A GYP include file for building a Node.js native add-on.
18
+ #
19
+ # Main documentation:
20
+ #
21
+ # [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
22
+ # [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
23
+ {
24
+ # Define variables to be used throughout the configuration for all targets:
25
+ 'variables': {
26
+ # Source directory:
27
+ 'src_dir': './src',
28
+
29
+ # Include directories:
30
+ 'include_dirs': [
31
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
32
+ ],
33
+
34
+ # Add-on destination directory:
35
+ 'addon_output_dir': './src',
36
+
37
+ # Source files:
38
+ 'src_files': [
39
+ '<(src_dir)/addon.c',
40
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
41
+ ],
42
+
43
+ # Library dependencies:
44
+ 'libraries': [
45
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
46
+ ],
47
+
48
+ # Library directories:
49
+ 'library_dirs': [
50
+ '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
51
+ ],
52
+ }, # end variables
53
+ }
package/lib/index.js CHANGED
@@ -41,9 +41,9 @@
41
41
 
42
42
  // MODULES //
43
43
 
44
- var ceiln = require( './ceiln.js' );
44
+ var main = require( './main.js' );
45
45
 
46
46
 
47
47
  // EXPORTS //
48
48
 
49
- module.exports = ceiln;
49
+ module.exports = main;
@@ -91,7 +91,6 @@ var HUGE = 1.0e+308;
91
91
  * \end{align*}
92
92
  * ```
93
93
  *
94
- *
95
94
  * @param {number} x - input value
96
95
  * @param {integer} n - integer power of 10
97
96
  * @returns {number} rounded value
package/lib/native.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2023 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var addon = require( './../src/addon.node' );
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * Rounds a double-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity.
30
+ *
31
+ * @private
32
+ * @param {number} x - input value
33
+ * @param {integer} n - integer power of 10
34
+ * @returns {number} rounded value
35
+ *
36
+ * @example
37
+ * // Round a value to 2 decimal places:
38
+ * var v = ceiln( 3.141592653589793, -2 );
39
+ * // returns 3.15
40
+ *
41
+ * @example
42
+ * // If n = 0, `ceiln` behaves like `ceil`:
43
+ * var v = ceiln( 3.141592653589793, 0 );
44
+ * // returns 4.0
45
+ *
46
+ * @example
47
+ * // Round a value to the nearest thousand:
48
+ * var v = ceiln( 12368.0, 3 );
49
+ * // returns 13000.0
50
+ */
51
+ function ceiln( x, n ) {
52
+ return addon( x, n );
53
+ }
54
+
55
+
56
+ // EXPORTS //
57
+
58
+ module.exports = ceiln;
package/manifest.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "options": {
3
+ "task": "build"
4
+ },
5
+ "fields": [
6
+ {
7
+ "field": "src",
8
+ "resolve": true,
9
+ "relative": true
10
+ },
11
+ {
12
+ "field": "include",
13
+ "resolve": true,
14
+ "relative": true
15
+ },
16
+ {
17
+ "field": "libraries",
18
+ "resolve": false,
19
+ "relative": false
20
+ },
21
+ {
22
+ "field": "libpath",
23
+ "resolve": true,
24
+ "relative": false
25
+ }
26
+ ],
27
+ "confs": [
28
+ {
29
+ "task": "build",
30
+ "src": [
31
+ "./src/ceiln.c"
32
+ ],
33
+ "include": [
34
+ "./include"
35
+ ],
36
+ "libraries": [
37
+ "-lm"
38
+ ],
39
+ "libpath": [],
40
+ "dependencies": [
41
+ "@stdlib/math-base-napi-binary",
42
+ "@stdlib/math-base-special-abs",
43
+ "@stdlib/math-base-special-ceil",
44
+ "@stdlib/math-base-assert-is-nan",
45
+ "@stdlib/math-base-assert-is-infinite",
46
+ "@stdlib/constants-float64-max-base10-exponent",
47
+ "@stdlib/constants-float64-min-base10-exponent",
48
+ "@stdlib/constants-float64-min-base10-exponent-subnormal",
49
+ "@stdlib/constants-float64-max-safe-integer",
50
+ "@stdlib/constants-float64-pinf"
51
+ ]
52
+ },
53
+ {
54
+ "task": "benchmark",
55
+ "src": [
56
+ "./src/ceiln.c"
57
+ ],
58
+ "include": [
59
+ "./include"
60
+ ],
61
+ "libraries": [
62
+ "-lm"
63
+ ],
64
+ "libpath": [],
65
+ "dependencies": [
66
+ "@stdlib/math-base-special-abs",
67
+ "@stdlib/math-base-special-ceil",
68
+ "@stdlib/math-base-assert-is-nan",
69
+ "@stdlib/math-base-assert-is-infinite",
70
+ "@stdlib/constants-float64-max-base10-exponent",
71
+ "@stdlib/constants-float64-min-base10-exponent",
72
+ "@stdlib/constants-float64-min-base10-exponent-subnormal",
73
+ "@stdlib/constants-float64-max-safe-integer",
74
+ "@stdlib/constants-float64-pinf"
75
+ ]
76
+ },
77
+ {
78
+ "task": "examples",
79
+ "src": [
80
+ "./src/ceiln.c"
81
+ ],
82
+ "include": [
83
+ "./include"
84
+ ],
85
+ "libraries": [
86
+ "-lm"
87
+ ],
88
+ "libpath": [],
89
+ "dependencies": [
90
+ "@stdlib/math-base-special-abs",
91
+ "@stdlib/math-base-special-ceil",
92
+ "@stdlib/math-base-assert-is-nan",
93
+ "@stdlib/math-base-assert-is-infinite",
94
+ "@stdlib/constants-float64-max-base10-exponent",
95
+ "@stdlib/constants-float64-min-base10-exponent",
96
+ "@stdlib/constants-float64-min-base10-exponent-subnormal",
97
+ "@stdlib/constants-float64-max-safe-integer",
98
+ "@stdlib/constants-float64-pinf"
99
+ ]
100
+ }
101
+ ]
102
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/math-base-special-ceiln",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "description": "Round a numeric value to the nearest multiple of 10^n toward positive infinity.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -14,11 +14,14 @@
14
14
  }
15
15
  ],
16
16
  "main": "./lib",
17
+ "gypfile": false,
17
18
  "directories": {
18
19
  "benchmark": "./benchmark",
19
20
  "doc": "./docs",
20
21
  "example": "./examples",
22
+ "include": "./include",
21
23
  "lib": "./lib",
24
+ "src": "./src",
22
25
  "test": "./test"
23
26
  },
24
27
  "types": "./docs/types",
@@ -37,29 +40,32 @@
37
40
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
41
  },
39
42
  "dependencies": {
40
- "@stdlib/constants-float64-max-base10-exponent": "^0.0.x",
41
- "@stdlib/constants-float64-max-safe-integer": "^0.0.x",
42
- "@stdlib/constants-float64-min-base10-exponent": "^0.0.x",
43
- "@stdlib/constants-float64-min-base10-exponent-subnormal": "^0.0.x",
44
- "@stdlib/constants-float64-pinf": "^0.0.x",
45
- "@stdlib/math-base-assert-is-infinite": "^0.0.x",
46
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
47
- "@stdlib/math-base-special-abs": "^0.0.x",
48
- "@stdlib/math-base-special-ceil": "^0.0.x",
49
- "@stdlib/math-base-special-pow": "^0.0.x"
43
+ "@stdlib/constants-float64-max-base10-exponent": "^0.1.0",
44
+ "@stdlib/constants-float64-max-safe-integer": "^0.1.0",
45
+ "@stdlib/constants-float64-min-base10-exponent": "^0.1.0",
46
+ "@stdlib/constants-float64-min-base10-exponent-subnormal": "^0.1.0",
47
+ "@stdlib/constants-float64-pinf": "^0.1.0",
48
+ "@stdlib/math-base-assert-is-infinite": "^0.1.0",
49
+ "@stdlib/math-base-assert-is-nan": "^0.1.0",
50
+ "@stdlib/math-base-napi-binary": "^0.1.0",
51
+ "@stdlib/math-base-special-abs": "^0.1.0",
52
+ "@stdlib/math-base-special-ceil": "^0.1.0",
53
+ "@stdlib/math-base-special-pow": "^0.1.0",
54
+ "@stdlib/utils-library-manifest": "^0.1.0"
50
55
  },
51
56
  "devDependencies": {
52
- "@stdlib/bench": "^0.0.x",
53
- "@stdlib/constants-float64-eps": "^0.0.x",
54
- "@stdlib/constants-float64-ninf": "^0.0.x",
55
- "@stdlib/constants-float64-pi": "^0.0.x",
56
- "@stdlib/math-base-assert-is-negative-zero": "^0.0.x",
57
- "@stdlib/math-base-assert-is-positive-zero": "^0.0.x",
58
- "@stdlib/math-base-special-round": "^0.0.x",
59
- "@stdlib/random-base-randu": "^0.0.x",
57
+ "@stdlib/bench": "^0.1.0",
58
+ "@stdlib/constants-float64-eps": "^0.1.0",
59
+ "@stdlib/constants-float64-ninf": "^0.1.0",
60
+ "@stdlib/constants-float64-pi": "^0.1.0",
61
+ "@stdlib/math-base-assert-is-negative-zero": "^0.1.0",
62
+ "@stdlib/math-base-assert-is-positive-zero": "^0.1.0",
63
+ "@stdlib/math-base-special-round": "^0.1.0",
64
+ "@stdlib/random-base-randu": "^0.0.8",
65
+ "@stdlib/utils-try-require": "^0.1.0",
60
66
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
61
67
  "istanbul": "^0.4.1",
62
- "tap-spec": "5.x.x"
68
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
63
69
  },
64
70
  "engines": {
65
71
  "node": ">=0.10.0",
@@ -92,7 +98,7 @@
92
98
  "number"
93
99
  ],
94
100
  "funding": {
95
- "type": "patreon",
96
- "url": "https://www.patreon.com/athan"
101
+ "type": "opencollective",
102
+ "url": "https://opencollective.com/stdlib"
97
103
  }
98
104
  }
package/src/addon.c ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2023 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "stdlib/math/base/special/ceiln.h"
20
+ #include "stdlib/math/base/napi/binary.h"
21
+
22
+ STDLIB_MATH_BASE_NAPI_MODULE_DI_D( stdlib_base_ceiln )
package/src/ceiln.c ADDED
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2023 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "stdlib/math/base/special/ceiln.h"
20
+ #include "stdlib/math/base/special/ceil.h"
21
+ #include "stdlib/math/base/special/abs.h"
22
+ #include "stdlib/math/base/assert/is_nan.h"
23
+ #include "stdlib/math/base/assert/is_infinite.h"
24
+ #include "stdlib/constants/float64/max_base10_exponent.h"
25
+ #include "stdlib/constants/float64/min_base10_exponent.h"
26
+ #include "stdlib/constants/float64/min_base10_exponent_subnormal.h"
27
+ #include "stdlib/constants/float64/max_safe_integer.h"
28
+ #include "stdlib/constants/float64/pinf.h"
29
+ #include <stdint.h>
30
+ #include <math.h>
31
+
32
+
33
+ // VARIABLES //
34
+
35
+ static const double MAX_INT = STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER + 1.0;
36
+ static const double HUGE = 1.0e+308;
37
+
38
+
39
+ // MAIN //
40
+
41
+ /**
42
+ * Rounds a double-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity.
43
+ *
44
+ * @param x input value
45
+ * @param n integer power of 10
46
+ * @return rounded value
47
+ *
48
+ * @example
49
+ * // Round a value to 2 decimal places:
50
+ * double y = stdlib_base_ceiln( 3.141592653589793, -2 );
51
+ * // returns 3.15
52
+ *
53
+ * @example
54
+ * // If n = 0, `ceiln` behaves like `ceil`:
55
+ * double y = stdlib_base_ceiln( 3.141592653589793, 0 );
56
+ * // returns 4.0
57
+ *
58
+ * @example
59
+ * // Round a value to the nearest thousand:
60
+ * double y = stdlib_base_ceiln( 12368.0, 3 );
61
+ * // returns 13000.0
62
+ */
63
+ double stdlib_base_ceiln( const double x, const int32_t n ) {
64
+ double s;
65
+ double y;
66
+ if ( stdlib_base_is_nan( x ) ){
67
+ return x;
68
+ }
69
+ if (
70
+ // Handle infinities...
71
+ stdlib_base_is_infinite( x ) ||
72
+
73
+ // Handle +-0...
74
+ x == 0.0 ||
75
+
76
+ // If `n` exceeds the maximum number of feasible decimal places (such as with subnormal numbers), nothing to round...
77
+ n < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT_SUBNORMAL ||
78
+
79
+ // If `|x|` is large enough, no decimals to round...
80
+ ( stdlib_base_abs( x ) > MAX_INT && n <= 0 )
81
+ ) {
82
+ return x;
83
+ }
84
+ // 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.
85
+ if ( n > STDLIB_CONSTANT_FLOAT64_MAX_BASE10_EXPONENT ) {
86
+ if ( x <= 0.0 ) {
87
+ return -0.0; // preserve the sign (same behavior as ceil)
88
+ }
89
+ return STDLIB_CONSTANT_FLOAT64_PINF;
90
+ }
91
+ // 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...
92
+ if ( n < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT ) {
93
+ s = pow( 10.0, -( n + STDLIB_CONSTANT_FLOAT64_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent
94
+ y = ( x * HUGE ) * s; // order of operation matters!
95
+ if ( stdlib_base_is_infinite( y ) ) {
96
+ return x;
97
+ }
98
+ return ( stdlib_base_ceil( y ) / HUGE ) / s;
99
+ }
100
+ s = pow( 10.0, -n ); // TODO: replace use of `pow` once have stdlib equivalent
101
+ y = x * s;
102
+ if ( stdlib_base_is_infinite( y ) ) {
103
+ return x;
104
+ }
105
+ return stdlib_base_ceil( y ) / s;
106
+ }
package/docs/repl.txt DELETED
@@ -1,39 +0,0 @@
1
-
2
- {{alias}}( x, n )
3
- Rounds a numeric value to the nearest multiple of `10^n` toward positive
4
- infinity.
5
-
6
- When operating on floating-point numbers in bases other than `2`, rounding
7
- to specified digits can be inexact.
8
-
9
- Parameters
10
- ----------
11
- x: number
12
- Input value.
13
-
14
- n: integer
15
- Integer power of 10.
16
-
17
- Returns
18
- -------
19
- y: number
20
- Rounded value.
21
-
22
- Examples
23
- --------
24
- // Round to 2 decimal places:
25
- > var y = {{alias}}( 3.14159, -2 )
26
- 3.15
27
-
28
- // If `n = 0`, standard round toward positive infinity behavior:
29
- > y = {{alias}}( 3.14159, 0 )
30
- 4.0
31
-
32
- // Round to nearest thousand:
33
- > y = {{alias}}( 12368.0, 3 )
34
- 13000.0
35
-
36
-
37
- See Also
38
- --------
39
-
@@ -1,56 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2019 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import ceiln = require( './index' );
20
-
21
-
22
- // TESTS //
23
-
24
- // The function returns a number...
25
- {
26
- ceiln( 3.141592653589793, -4 ); // $ExpectType number
27
- }
28
-
29
- // The function does not compile if provided values other than two numbers...
30
- {
31
- ceiln( true, 3 ); // $ExpectError
32
- ceiln( false, 2 ); // $ExpectError
33
- ceiln( '5', 1 ); // $ExpectError
34
- ceiln( [], 1 ); // $ExpectError
35
- ceiln( {}, 2 ); // $ExpectError
36
- ceiln( ( x: number ): number => x, 2 ); // $ExpectError
37
-
38
- ceiln( 9, true ); // $ExpectError
39
- ceiln( 9, false ); // $ExpectError
40
- ceiln( 5, '5' ); // $ExpectError
41
- ceiln( 8, [] ); // $ExpectError
42
- ceiln( 9, {} ); // $ExpectError
43
- ceiln( 8, ( x: number ): number => x ); // $ExpectError
44
-
45
- ceiln( [], true ); // $ExpectError
46
- ceiln( {}, false ); // $ExpectError
47
- ceiln( false, '5' ); // $ExpectError
48
- ceiln( {}, [] ); // $ExpectError
49
- ceiln( '5', ( x: number ): number => x ); // $ExpectError
50
- }
51
-
52
- // The function does not compile if provided insufficient arguments...
53
- {
54
- ceiln(); // $ExpectError
55
- ceiln( 3 ); // $ExpectError
56
- }