time-to-botec

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

README.md (2245B)


      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 # isPositiveInteger
     22 
     23 > Test if a finite [double-precision floating-point number][ieee754] is a positive integer.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isPositiveInteger = require( '@stdlib/math/base/assert/is-positive-integer' );
     31 ```
     32 
     33 #### isPositiveInteger( x )
     34 
     35 Tests if a finite [double-precision floating-point number][ieee754] is a positive `integer`.
     36 
     37 ```javascript
     38 var bool = isPositiveInteger( 1.0 );
     39 // returns true
     40 
     41 bool = isPositiveInteger( 0.0 );
     42 // returns false
     43 
     44 bool = isPositiveInteger( -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             isPositiveInteger( x )
     63         );
     64     }
     65 
     66     var bool = check( Infinity );
     67     // returns false
     68     ```
     69 
     70 </section>
     71 
     72 <!-- /.notes -->
     73 
     74 <section class="examples">
     75 
     76 ## Examples
     77 
     78 <!-- eslint no-undef: "error" -->
     79 
     80 ```javascript
     81 var isPositiveInteger = require( '@stdlib/math/base/assert/is-positive-integer' );
     82 
     83 var bool = isPositiveInteger( 5.0 );
     84 // returns true
     85 
     86 bool = isPositiveInteger( 0.0 );
     87 // returns false
     88 
     89 bool = isPositiveInteger( -1.0 );
     90 // returns false
     91 
     92 bool = isPositiveInteger( 3.14 );
     93 // returns false
     94 
     95 bool = isPositiveInteger( NaN );
     96 // returns false
     97 ```
     98 
     99 </section>
    100 
    101 <!-- /.examples -->
    102 
    103 <section class="links">
    104 
    105 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
    106 
    107 </section>
    108 
    109 <!-- /.links -->