time-to-botec

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

README.md (3534B)


      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 # High Word
     22 
     23 > Return an unsigned 32-bit integer corresponding to the more significant 32 bits of a [double-precision floating-point number][ieee754].
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var getHighWord = require( '@stdlib/number/float64/base/get-high-word' );
     31 ```
     32 
     33 #### getHighWord( x )
     34 
     35 Returns an unsigned 32-bit `integer` corresponding to the more significant 32 bits of a [double-precision floating-point number][ieee754].
     36 
     37 ```javascript
     38 var w = getHighWord( 3.14e201 ); // => 01101001110001001000001011000011
     39 // returns 1774486211
     40 ```
     41 
     42 </section>
     43 
     44 <!-- /.usage -->
     45 
     46 <section class="examples">
     47 
     48 ## Examples
     49 
     50 <!-- eslint no-undef: "error" -->
     51 
     52 ```javascript
     53 var floor = require( '@stdlib/math/base/special/floor' );
     54 var randu = require( '@stdlib/random/base/randu' );
     55 var pow = require( '@stdlib/math/base/special/pow' );
     56 var getHighWord = require( '@stdlib/number/float64/base/get-high-word' );
     57 
     58 var frac;
     59 var exp;
     60 var w;
     61 var x;
     62 var i;
     63 
     64 for ( i = 0; i < 100; i++ ) {
     65     frac = randu() * 10.0;
     66     exp = -floor( randu()*324.0 );
     67     x = frac * pow( 10.0, exp );
     68     w = getHighWord( x );
     69     console.log( 'x: %d. high word: %d.', x, w );
     70 }
     71 ```
     72 
     73 </section>
     74 
     75 <!-- /.examples -->
     76 
     77 <!-- C interface documentation. -->
     78 
     79 * * *
     80 
     81 <section class="c">
     82 
     83 ## C APIs
     84 
     85 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     86 
     87 <section class="intro">
     88 
     89 </section>
     90 
     91 <!-- /.intro -->
     92 
     93 <!-- C usage documentation. -->
     94 
     95 <section class="usage">
     96 
     97 ### Usage
     98 
     99 ```c
    100 #include "stdlib/number/float64/base/get_high_word.h"
    101 ```
    102 
    103 #### stdlib_base_float64_get_high_word( x, \*high )
    104 
    105 Extracts the unsigned 32-bit integer corresponding to the more significant 32 bits of a double-precision floating-point number.
    106 
    107 ```c
    108 #include <stdint.h>
    109 
    110 uint32_t high;
    111 stdlib_base_float64_get_high_word( 3.14, &high );
    112 ```
    113 
    114 The function accepts the following arguments:
    115 
    116 -   **x**: `[in] double` input value.
    117 -   **high**: `[out] uint32_t*` destination for higher order word.
    118 
    119 ```c
    120 void stdlib_base_float64_get_high_word( const double x, uint32_t *high );
    121 ```
    122 
    123 </section>
    124 
    125 <!-- /.usage -->
    126 
    127 <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    128 
    129 <section class="notes">
    130 
    131 </section>
    132 
    133 <!-- /.notes -->
    134 
    135 <!-- C API usage examples. -->
    136 
    137 <section class="examples">
    138 
    139 ### Examples
    140 
    141 ```c
    142 #include "stdlib/number/float64/base/get_high_word.h"
    143 #include <stdint.h>
    144 #include <stdio.h>
    145 
    146 int main() {
    147     double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 };
    148 
    149     uint32_t high;
    150     int i;
    151     for ( i = 0; i < 4; i++ ) {
    152         stdlib_base_float64_get_high_word( x[ i ], &high );
    153         printf( "%lf => high: %u\n", x[ i ], high );
    154     }
    155 }
    156 ```
    157 
    158 </section>
    159 
    160 <!-- /.examples -->
    161 
    162 </section>
    163 
    164 <!-- /.c -->
    165 
    166 <section class="links">
    167 
    168 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
    169 
    170 </section>
    171 
    172 <!-- /.links -->