const { bitview, bitIndices } = require('./helpers/bitwise.js');
// โญ test 32-bit signed integers
const M = 2 ** 32; // 4294967296
const m = M/8; // 536870912
// log
[
bitview(M).indexed,
// โ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|
// --------------------------------
// 00000000000000000000000000000000 // M = 2^32
bitview(m).indexed,
// โ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|
// --------------------------------
// 00100000000000000000000000000000 // m = M/8
bitview(1234, {leadingZeros: false}).indexed,
// |โนโธโทโถโตโโโโ|
// -----------
// 10011010010 // 1234
bitview(1234).indexed,
bitview(~1234).raw,
bitview(-1234).raw,
// โ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|
// --------------------------------
// 00000000000000000000010011010010 // 1234
// 11111111111111111111101100101101 // ~1234 (bits inverted)
// 11111111111111111111101100101110 // -1234 (= ~x + 1)
bitIndices({number: 1234}),
// |โนโธโทโถโตโโโโ|
// -----------
bitview(1234, {leadingZeros: false}).raw,
// 10011010010 // 1234
(1234).toString(2), // (same as above, but shorter)
// 10011010010 // 1234
bitIndices(), // 32-bit bit indices
// โ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|
// --------------------------------
bitview(-1).raw,
// 11111111111111111111111111111111 // -1
bitview(-2).equation,
// (-2)โโ = (11111111111111111111111111111110)โ
bitview(3, {leadingZeros: false}).equation,
// (3)โโ = (11)โ
'--------------------',
// โ toString(2) doesn't show 2's complement for negative integers.
// โโ โ minus sign (-) is kept.
(-12).toString(2), // -1100 (what the โ)
(~~(-12)).toString(2), // -1100 (what the โ)
bitview(-1234).indexed,
// โ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|โนโธโทโถโตโโโโ|
// --------------------------------
// 11111111111111111111101100101110 // -1234
(-1234).toString(2), // -10011010010
(-1234).toString(2).length, // 12
].forEach(x => console.log(x));