time-to-botec

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

README.md (1991B)


      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 # signbit
     22 
     23 > Return a boolean indicating if the sign bit for a [single-precision floating-point number][ieee754] is on (true) or off (false).
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var signbitf = require( '@stdlib/number/float32/base/signbit' );
     31 ```
     32 
     33 #### signbitf( x )
     34 
     35 Returns a `boolean` indicating if the sign bit for a [single-precision floating-point number][ieee754] is on (`true`) or off (`false`).
     36 
     37 ```javascript
     38 var toFloat32 = require( '@stdlib/number/float64/base/to-float32' );
     39 
     40 var bool = signbitf( toFloat32( 4.0 ) );
     41 // returns false
     42 
     43 bool = signbitf( toFloat32( -9.14e-34 ) );
     44 // returns true
     45 
     46 bool = signbitf( 0.0 );
     47 // returns false
     48 
     49 bool = signbitf( -0.0 );
     50 // returns true
     51 ```
     52 
     53 </section>
     54 
     55 <!-- /.usage -->
     56 
     57 <section class="examples">
     58 
     59 ## Examples
     60 
     61 <!-- eslint no-undef: "error" -->
     62 
     63 ```javascript
     64 var toFloat32 = require( '@stdlib/number/float64/base/to-float32' );
     65 var randu = require( '@stdlib/random/base/randu' );
     66 var signbitf = require( '@stdlib/number/float32/base/signbit' );
     67 
     68 var sign;
     69 var x;
     70 var i;
     71 
     72 for ( i = 0; i < 100; i++ ) {
     73     x = (randu()*100.0) - 50.0;
     74     x = toFloat32( x );
     75     sign = signbitf( x );
     76     sign = ( sign ) ? 'true' : 'false';
     77     console.log( 'x: %d. signbit: %s.', x, sign );
     78 }
     79 ```
     80 
     81 </section>
     82 
     83 <!-- /.examples -->
     84 
     85 <section class="links">
     86 
     87 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
     88 
     89 </section>
     90 
     91 <!-- /.links -->