Namespace: rlUtilsConvert

rlUtilsConvert

Methods

(static) i32ToBinaryString(n) → {string}

Convert a 32bit number to a string containing 32 characters: a 1 for each set bit and a 0 for each unset bit.
e.g. 666 --> "00000000000000000000001010011010"
-1337 --> "11111111111111111111101011000111"
(the javascript number type is actually a 64bit floating point number, so if you pass in anything which is not integral and outside the 32bit range for signed integers, the result may contain unexpected bits)

Parameters:
Name Type Description
n number

the 32bit number to convert

Returns:

a string containing 32 chars, each char being either a 1 or a 0 or "NaN" if n was not a number

Type
string

(static) nToMinLengthString(n, radix, minLength) → {string}

Like n.toString(radix) but fills up zeroes on the left until resulting string is at least as long as the given minLength.

Parameters:
Name Type Description
n Number

the number to convert

radix Number

to be passed to n.toString

minLength Number

the minimum length of the resulting string

Returns:
Type
string