time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2139B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # ceil10
     22 
     23 > Round a numeric value to the nearest power of 10 toward positive infinity.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var ceil10 = require( '@stdlib/math/base/special/ceil10' );
     31 ```
     32 
     33 #### ceil10( x )
     34 
     35 Rounds a `numeric` value to the nearest power of `10` toward positive infinity.
     36 
     37 ```javascript
     38 var v = ceil10( -4.2 );
     39 // returns -1.0
     40 
     41 v = ceil10( -4.5 );
     42 // returns -1.0
     43 
     44 v = ceil10( -4.6 );
     45 // returns -1.0
     46 
     47 v = ceil10( 9.99999 );
     48 // returns 10.0
     49 
     50 v = ceil10( 9.5 );
     51 // returns 10.0
     52 
     53 v = ceil10( 13.0 );
     54 // returns 100.0
     55 
     56 v = ceil10( -13.0 );
     57 // returns -10.0
     58 
     59 v = ceil10( 0.0 );
     60 // returns 0.0
     61 
     62 v = ceil10( -0.0 );
     63 // returns -0.0
     64 
     65 v = ceil10( Infinity );
     66 // returns Infinity
     67 
     68 v = ceil10( -Infinity );
     69 // returns -Infinity
     70 
     71 v = ceil10( NaN );
     72 // returns NaN
     73 ```
     74 
     75 </section>
     76 
     77 <!-- /.usage -->
     78 
     79 <section class="notes">
     80 
     81 ## Notes
     82 
     83 -   The function may not return accurate results for subnormals due to a general loss in precision.
     84 
     85     ```javascript
     86     var v = ceil10( -1.0e-323 ); // should return -1.0e-323
     87     // returns -0.0
     88     ```
     89 
     90 </section>
     91 
     92 <!-- /.notes -->
     93 
     94 <section class="examples">
     95 
     96 ## Examples
     97 
     98 <!-- eslint no-undef: "error" -->
     99 
    100 ```javascript
    101 var randu = require( '@stdlib/random/base/randu' );
    102 var ceil10 = require( '@stdlib/math/base/special/ceil10' );
    103 
    104 var x;
    105 var v;
    106 var i;
    107 
    108 for ( i = 0; i < 100; i++ ) {
    109     x = (randu()*100.0) - 50.0;
    110     v = ceil10( x );
    111     console.log( 'Value: %d. Rounded: %d.', x, v );
    112 }
    113 ```
    114 
    115 </section>
    116 
    117 <!-- /.examples -->
    118 
    119 <section class="links">
    120 
    121 </section>
    122 
    123 <!-- /.links -->