@wider/utils_proto/proto_number

Provide extensions to the javascript Number prototype

Author:
  • Martin W Baker
License:
  • ISC 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.

Methods

inner bitsUpTo()() → {BigInteger}

fills all the bits lower than the most significant bit with 1's

eg given any value 8 to 15 returns 15 since 2^3 is the most significant bit 100 in binary and so we have binary(1111) = 15 as all the bits

used predominantly in bit implication logics with masks

Returns:
BigInteger

inner two()() → {string}

always give the n (default 2 hence its chosen name) digits before the decimal place of a number - padding with 0 at left if need be

if number is NaN then this returns aN

Returns:
string