-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo.js
89 lines (61 loc) · 1.24 KB
/
algo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { create, all } from 'mathjs';
const config = {
matrix: 'Array',
};
const math = create(all, config);
math.range(0, 4);
math.config({
matrix: 'Matrix',
});
math.range(0, 4);
const bigmath = create(all, {
number: 'BigNumber',
precision: 32,
});
const dividir = bigmath.evaluate('1/3');
dividir;
// const config = {
// epsilon: 1e-12,
// matrix: 'Matrix',
// number: 'number',
// precision: 64,
// predictable: false,
// randomSeed: null,
// };
// const math = create(all, config);
// console.log(math.config());
// math.config({
// number: 'BigNumber',
// });
const calc = ['1', 'x', '4', '+', '5'];
calc;
const setCalc = calc.join();
setCalc;
const index = calc.indexOf('x');
if (index !== -1) {
calc[index] = '*';
}
calc;
const setCalcNew = calc.join('');
setCalcNew;
const multipl = math.evaluate(setCalcNew);
multipl;
console.log(typeof setCalcNew);
function calculo() {
const soma = parseInt(setCalcNew);
console.log(soma);
return soma;
}
function multi(a, b) {
return a * b;
}
console.log(calculo());
console.log(multi(2, 3));
console.log(2 * 3);
const num = '43743x43';
const parsed = num.split('');
const indexNum = parsed.indexOf('x');
if (indexNum !== -1) {
parsed[indexNum] = '*';
}
parsed;