1 | import { bitNotBigNumber } from '../../utils/bignumber/bitwise'
|
2 | import { deepMap } from '../../utils/collection'
|
3 | import { factory } from '../../utils/factory'
|
4 | import { bitNotNumber } from '../../plain/number'
|
5 |
|
6 | const name = 'bitNot'
|
7 | const dependencies = ['typed']
|
8 |
|
9 | export const createBitNot = /* #__PURE__ */ factory(name, dependencies, ({ typed }) => {
|
10 | /**
|
11 | * Bitwise NOT value, `~x`.
|
12 | * For matrices, the function is evaluated element wise.
|
13 | * For units, the function is evaluated on the best prefix base.
|
14 | *
|
15 | * Syntax:
|
16 | *
|
17 | * math.bitNot(x)
|
18 | *
|
19 | * Examples:
|
20 | *
|
21 | * math.bitNot(1) // returns number -2
|
22 | *
|
23 | * math.bitNot([2, -3, 4]) // returns Array [-3, 2, 5]
|
24 | *
|
25 | * See also:
|
26 | *
|
27 | * bitAnd, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
|
28 | *
|
29 | * @param {number | BigNumber | Array | Matrix} x Value to not
|
30 | * @return {number | BigNumber | Array | Matrix} NOT of `x`
|
31 | */
|
32 | const bitNot = typed(name, {
|
33 | number: bitNotNumber,
|
34 |
|
35 | BigNumber: bitNotBigNumber,
|
36 |
|
37 | 'Array | Matrix': function (x) {
|
38 | return deepMap(x, bitNot)
|
39 | }
|
40 | })
|
41 |
|
42 | return bitNot
|
43 | })
|