From ee4a63684e517085595b3ec3c9fd0ee3711bcb10 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 17 Mar 2024 02:36:57 +0000 Subject: [PATCH] Update artifacts --- .../base/from-binary-string/coverage.ndjson | 1 + .../uint16/base/from-binary-string/index.html | 131 +++++++ .../base/from-binary-string/index.js.html | 244 +++++++++++++ .../base/from-binary-string/main.js.html | 322 ++++++++++++++++++ string/base/last/coverage.ndjson | 1 + string/base/last/index.html | 2 +- string/base/last/index.js.html | 2 +- string/base/last/main.js.html | 2 +- 8 files changed, 702 insertions(+), 3 deletions(-) create mode 100644 number/uint16/base/from-binary-string/coverage.ndjson create mode 100644 number/uint16/base/from-binary-string/index.html create mode 100644 number/uint16/base/from-binary-string/index.js.html create mode 100644 number/uint16/base/from-binary-string/main.js.html diff --git a/number/uint16/base/from-binary-string/coverage.ndjson b/number/uint16/base/from-binary-string/coverage.ndjson new file mode 100644 index 0000000000..fc07522cf7 --- /dev/null +++ b/number/uint16/base/from-binary-string/coverage.ndjson @@ -0,0 +1 @@ +[132,132,100,8,8,100,1,1,100,132,132,100,"0616f00c08b92c0c40ac1a1cabee46994e8d6d63","2024-03-16 22:35:17 -0400"] diff --git a/number/uint16/base/from-binary-string/index.html b/number/uint16/base/from-binary-string/index.html new file mode 100644 index 0000000000..40c4ca8689 --- /dev/null +++ b/number/uint16/base/from-binary-string/index.html @@ -0,0 +1,131 @@ + + + + +
++ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ ++ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Create an unsigned 16-bit integer from a literal bit representation. +* +* @module @stdlib/number/uint16/base/from-binary-string +* +* @example +* var fromBinaryStringUint16 = require( '@stdlib/number/uint16/base/from-binary-string' ); +* +* var bstr = '0101010101010101'; +* var val = fromBinaryStringUint16( bstr ); +* // returns 21845 +* +* bstr = '0000000000000000'; +* val = fromBinaryStringUint16( bstr ); +* // returns 0 +* +* bstr = '0000000000000010'; +* val = fromBinaryStringUint16( bstr ); +* // returns 2 +* +* bstr = '1111111111111111'; +* val = fromBinaryStringUint16( bstr ); +* // returns 65535 +*/ + +// MODULES // + +var fromBinaryStringUint16 = require( './main.js' ); + + +// EXPORTS // + +module.exports = fromBinaryStringUint16; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1010x +1010x +1010x +1010x +7x +7x +1003x +1010x +16048x +7990x +7990x +16048x +1003x +1010x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var pow = require( '@stdlib/math/base/special/pow' ); + + +// VARIABLES // + +var NBITS = 16; + + +// MAIN // + +/** +* Creates an unsigned 16-bit integer from a literal bit representation. +* +* @param {BinaryString} bstr - string which is a literal bit representation +* @throws {Error} must provide a string with a length equal to `16` +* @returns {uinteger16} unsigned 16-bit integer +* +* @example +* var bstr = '0101010101010101'; +* var val = fromBinaryStringUint16( bstr ); +* // returns 21845 +* +* @example +* var bstr = '0000000000000000'; +* var val = fromBinaryStringUint16( bstr ); +* // returns 0 +* +* @example +* var bstr = '0000000000000010'; +* var val = fromBinaryStringUint16( bstr ); +* // returns 2 +* +* @example +* var bstr = '1111111111111111'; +* var val = fromBinaryStringUint16( bstr ); +* // returns 65535 +*/ +function fromBinaryStringUint16( bstr ) { + var sum; + var i; + if ( bstr.length !== NBITS ) { + throw new Error( format( 'invalid argument. Input string must have a length equal to %u. Value: `%s`.', NBITS, bstr ) ); + } + sum = 0; + for ( i = 0; i < bstr.length; i++ ) { + if ( bstr[ i ] === '1' ) { + sum += pow( 2, (NBITS-i-1) ); + } + } + return sum; +} + + +// EXPORTS // + +module.exports = fromBinaryStringUint16; + |