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