1 | 'use strict'
|
2 |
|
3 | const deepMap = require('../../utils/collection/deepMap')
|
4 | const bigBitNot = require('../../utils/bignumber/bitNot')
|
5 | const isInteger = require('../../utils/number').isInteger
|
6 |
|
7 | function factory (type, config, load, typed) {
|
8 | const latex = require('../../utils/latex')
|
9 |
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | const bitNot = typed('bitNot', {
|
33 | 'number': function (x) {
|
34 | if (!isInteger(x)) {
|
35 | throw new Error('Integer expected in function bitNot')
|
36 | }
|
37 |
|
38 | return ~x
|
39 | },
|
40 |
|
41 | 'BigNumber': bigBitNot,
|
42 |
|
43 | 'Array | Matrix': function (x) {
|
44 | return deepMap(x, bitNot)
|
45 | }
|
46 | })
|
47 |
|
48 | bitNot.toTex = {
|
49 | 1: latex.operators['bitNot'] + `\\left(\${args[0]}\\right)`
|
50 | }
|
51 |
|
52 | return bitNot
|
53 | }
|
54 |
|
55 | exports.name = 'bitNot'
|
56 | exports.factory = factory
|