index.js (2118B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 /** 22 * Return a string giving the literal bit representation of a single-precision floating-point number. 23 * 24 * @module @stdlib/number/float32/base/to-binary-string 25 * 26 * @example 27 * var toBinaryStringf = require( '@stdlib/number/float32/base/to-binary-string' ); 28 * var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); 29 * 30 * var str = toBinaryStringf( toFloat32( 4.0 ) ); 31 * // returns '01000000100000000000000000000000' 32 * 33 * str = toBinaryStringf( toFloat32( 3.141592653589793 ) ); 34 * // returns '01000000010010010000111111011011' 35 * 36 * str = toBinaryStringf( toFloat32( -1.0e38 ) ); 37 * // returns '11111110100101100111011010011001' 38 * 39 * str = toBinaryStringf( toFloat32( -3.14e-39 ) ); 40 * // returns '10000000001000100011000100001011' 41 * 42 * str = toBinaryStringf( toFloat32( 1.4e-45 ) ); 43 * // returns '00000000000000000000000000000001' 44 * 45 * str = toBinaryStringf( 0.0 ); 46 * // returns '00000000000000000000000000000000' 47 * 48 * str = toBinaryStringf( -0.0 ); 49 * // returns '10000000000000000000000000000000' 50 * 51 * str = toBinaryStringf( NaN ); 52 * // returns '01111111110000000000000000000000' 53 * 54 * var PINF = require( '@stdlib/constants/float32/pinf' ); 55 * str = toBinaryStringf( PINF ); 56 * // returns '01111111100000000000000000000000' 57 * 58 * var NINF = require( '@stdlib/constants/float32/ninf' ); 59 * str = toBinaryStringf( NINF ); 60 * // returns '11111111100000000000000000000000' 61 */ 62 63 // MODULES // 64 65 var totoBinaryStringf = require( './main.js' ); 66 67 68 // EXPORTS // 69 70 module.exports = totoBinaryStringf;