time-to-botec

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

README.md (2528B)


      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 # isNonNegativeInteger
     22 
     23 > Test if a finite [double-precision floating-point number][ieee754] is a nonnegative integer.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' );
     31 ```
     32 
     33 #### isNonNegativeInteger( x )
     34 
     35 Tests if a finite [double-precision floating-point number][ieee754] is a nonnegative `integer`.
     36 
     37 ```javascript
     38 var bool = isNonNegativeInteger( 1.0 );
     39 // returns true
     40 
     41 bool = isNonNegativeInteger( 0.0 );
     42 // returns true
     43 
     44 bool = isNonNegativeInteger( -10.0 );
     45 // returns false
     46 ```
     47 
     48 </section>
     49 
     50 <!-- /.usage -->
     51 
     52 <section class="notes">
     53 
     54 ## Notes
     55 
     56 -   The function assumes a **finite** `number`. If provided positive `infinity`, the function will return `true`, when, in fact, the result is undefined. If `x` can be `infinite`, wrap the implementation as follows:
     57 
     58     ```javascript
     59     function check( x ) {
     60         return (
     61             x < Infinity &&
     62             isNonNegativeInteger( x )
     63         );
     64     }
     65 
     66     var bool = check( Infinity );
     67     // returns false
     68     ```
     69 
     70 -   The function does **not** distinguish between positive and negative `zero`.
     71 
     72     ```javascript
     73     var bool = isNonNegativeInteger( 0.0 );
     74     // returns true
     75 
     76     bool = isNonNegativeInteger( -0.0 );
     77     // returns true
     78     ```
     79 
     80 </section>
     81 
     82 <!-- /.notes -->
     83 
     84 <section class="examples">
     85 
     86 ## Examples
     87 
     88 <!-- eslint no-undef: "error" -->
     89 
     90 ```javascript
     91 var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' );
     92 
     93 var bool = isNonNegativeInteger( 5.0 );
     94 // returns true
     95 
     96 bool = isNonNegativeInteger( 0.0 );
     97 // returns true
     98 
     99 bool = isNonNegativeInteger( -1.0 );
    100 // returns false
    101 
    102 bool = isNonNegativeInteger( 3.14 );
    103 // returns false
    104 
    105 bool = isNonNegativeInteger( NaN );
    106 // returns false
    107 ```
    108 
    109 </section>
    110 
    111 <!-- /.examples -->
    112 
    113 <section class="links">
    114 
    115 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
    116 
    117 </section>
    118 
    119 <!-- /.links -->