umt 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.markdownlint.json +4 -1
- package/README.md +11 -4
- package/module/Array/arraysJoin.d.ts +1 -2
- package/module/Array/arraysJoin.js +2 -1
- package/module/Array/getArraysCommon.d.ts +6 -0
- package/module/Array/getArraysCommon.js +25 -0
- package/module/Array/getArraysDiff.d.ts +1 -2
- package/module/Array/getArraysDiff.js +15 -7
- package/module/Array/index.d.ts +16 -5
- package/module/Array/index.js +54 -11
- package/module/Array/quickSort.d.ts +1 -2
- package/module/Array/quickSort.js +4 -3
- package/module/Array/sum.d.ts +1 -0
- package/module/Array/sum.js +8 -0
- package/module/Compiler/core.d.ts +5 -0
- package/module/Compiler/core.js +19 -0
- package/module/Compiler/token.d.ts +10 -0
- package/module/Compiler/token.js +120 -0
- package/module/Date/index.d.ts +7 -1
- package/module/Date/index.js +26 -5
- package/module/Date/now.d.ts +5 -2
- package/module/Date/now.js +10 -3
- package/module/Math/addition.d.ts +2 -2
- package/module/Math/addition.js +8 -9
- package/module/Math/average.d.ts +2 -2
- package/module/Math/average.js +3 -1
- package/module/Math/calculator/core.d.ts +1 -5
- package/module/Math/calculator/core.js +76 -55
- package/module/Math/calculator/exchange.d.ts +1 -5
- package/module/Math/calculator/exchange.js +16 -12
- package/module/Math/calculator/index.d.ts +2 -5
- package/module/Math/calculator/index.js +13 -8
- package/module/Math/calculator/literalExpression.d.ts +2 -2
- package/module/Math/calculator/literalExpression.js +20 -13
- package/module/Math/degToRad.d.ts +2 -2
- package/module/Math/degToRad.js +3 -1
- package/module/Math/deviationValue.d.ts +8 -0
- package/module/Math/deviationValue.js +14 -0
- package/module/Math/division.d.ts +7 -2
- package/module/Math/division.js +20 -9
- package/module/Math/factorial.d.ts +2 -2
- package/module/Math/factorial.js +10 -4
- package/module/Math/factorize.d.ts +2 -2
- package/module/Math/factorize.js +3 -1
- package/module/Math/gcd.d.ts +2 -2
- package/module/Math/gcd.js +6 -7
- package/module/Math/getDecimalLength.d.ts +2 -2
- package/module/Math/getDecimalLength.js +3 -1
- package/module/Math/index.d.ts +94 -33
- package/module/Math/index.js +278 -67
- package/module/Math/isDouble.d.ts +3 -2
- package/module/Math/isDouble.js +4 -1
- package/module/Math/isNumber.d.ts +3 -3
- package/module/Math/isNumber.js +4 -2
- package/module/Math/isPrimeNumber.d.ts +2 -2
- package/module/Math/isPrimeNumber.js +5 -6
- package/module/Math/lcm.d.ts +2 -2
- package/module/Math/lcm.js +7 -8
- package/module/Math/mathConverter.d.ts +5 -0
- package/module/Math/mathConverter.js +48 -0
- package/module/Math/mathSeparator.d.ts +5 -0
- package/module/Math/mathSeparator.js +21 -0
- package/module/Math/max.d.ts +1 -2
- package/module/Math/max.js +3 -2
- package/module/Math/min.d.ts +1 -2
- package/module/Math/min.js +3 -2
- package/module/Math/multiples.d.ts +1 -2
- package/module/Math/multiples.js +2 -1
- package/module/Math/multiplication.d.ts +1 -2
- package/module/Math/multiplication.js +4 -6
- package/module/Math/nCr.d.ts +1 -2
- package/module/Math/nCr.js +4 -6
- package/module/Math/nHr.d.ts +1 -2
- package/module/Math/nHr.js +4 -6
- package/module/Math/nPr.d.ts +1 -2
- package/module/Math/nPr.js +2 -1
- package/module/Math/primeFactorization.d.ts +1 -2
- package/module/Math/primeFactorization.js +2 -1
- package/module/Math/quotient.d.ts +1 -2
- package/module/Math/quotient.js +2 -1
- package/module/Math/radToDeg.d.ts +1 -2
- package/module/Math/radToDeg.js +2 -1
- package/module/Math/random.d.ts +3 -2
- package/module/Math/random.js +5 -2
- package/module/Math/reduce.d.ts +1 -2
- package/module/Math/reduce.js +5 -7
- package/module/Math/repeatedTrial.d.ts +2 -2
- package/module/Math/repeatedTrial.js +7 -8
- package/module/Math/roundOff.d.ts +7 -0
- package/module/Math/roundOff.js +14 -0
- package/module/Math/softmax.d.ts +5 -0
- package/module/Math/softmax.js +40 -0
- package/module/Math/standardDeviation.d.ts +1 -2
- package/module/Math/standardDeviation.js +5 -7
- package/module/Math/subtract.d.ts +1 -2
- package/module/Math/subtract.js +9 -9
- package/module/Math/toBinary.d.ts +5 -2
- package/module/Math/toBinary.js +4 -4
- package/module/Math/toCelsius.d.ts +1 -2
- package/module/Math/toCelsius.js +4 -6
- package/module/Math/toKelvin.d.ts +1 -2
- package/module/Math/toKelvin.js +4 -6
- package/module/Math/valueSwap.d.ts +2 -2
- package/module/Math/valueSwap.js +3 -1
- package/module/Simple/Date/index.d.ts +5 -0
- package/module/Simple/Date/index.js +27 -0
- package/module/Simple/Date/now.d.ts +1 -0
- package/module/Simple/Date/now.js +17 -0
- package/module/Simple/Math/dayOfWeek.d.ts +6 -0
- package/module/Simple/Math/dayOfWeek.js +31 -0
- package/module/Simple/Math/deviationValue.d.ts +5 -0
- package/module/Simple/Math/deviationValue.js +14 -0
- package/module/Simple/Math/index.d.ts +10 -0
- package/module/Simple/Math/index.js +33 -0
- package/module/Simple/Tool/birthday.d.ts +9 -0
- package/module/Simple/Tool/birthday.js +26 -0
- package/module/Simple/Tool/index.d.ts +5 -0
- package/module/Simple/Tool/index.js +27 -0
- package/module/Simple/index.d.ts +11 -0
- package/module/Simple/index.js +40 -0
- package/module/Tool/birthday.d.ts +8 -2
- package/module/Tool/birthday.js +15 -10
- package/module/Tool/dayOfWeek.d.ts +5 -6
- package/module/Tool/dayOfWeek.js +12 -2
- package/module/Tool/index.d.ts +18 -3
- package/module/Tool/index.js +58 -9
- package/module/Tool/isBrowser.d.ts +1 -0
- package/module/Tool/isBrowser.js +4 -0
- package/module/Tool/isNode.d.ts +1 -0
- package/module/Tool/isNode.js +4 -0
- package/module/Tool/isNodeWebkit.d.ts +1 -0
- package/module/Tool/isNodeWebkit.js +6 -0
- package/module/Tool/pipeFunction.d.ts +1 -2
- package/module/Tool/pipeFunction.js +3 -2
- package/module/index.d.ts +10 -11
- package/module/index.js +49 -33
- package/module/tsconfig.tsbuildinfo +1 -1
- package/module/types/int.d.ts +4 -0
- package/module/{Math/value.js → types/int.js} +0 -2
- package/module/types/logicType.d.ts +8 -0
- package/module/types/logicType.js +2 -0
- package/module/types/monType.d.ts +4 -0
- package/module/types/monType.js +2 -0
- package/package.json +18 -18
- package/.env +0 -1
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/node.js.yml +0 -30
- package/module/Array/getArraysIntersect.d.ts +0 -7
- package/module/Array/getArraysIntersect.js +0 -15
- package/module/Math/euclideanAlgorithm.d.ts +0 -8
- package/module/Math/euclideanAlgorithm.js +0 -31
- package/module/Math/value.d.ts +0 -2
- package/sider.yml +0 -60
- package/test.js +0 -5
|
@@ -1,71 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
3
|
+
exports.calculatorCore = void 0;
|
|
4
|
+
const addition_1 = require("../addition");
|
|
5
|
+
const division_1 = require("../division");
|
|
6
|
+
const multiplication_1 = require("../multiplication");
|
|
7
|
+
const subtract_1 = require("../subtract");
|
|
8
|
+
const exchange_1 = require("./exchange");
|
|
9
|
+
/**
|
|
10
|
+
* 電卓
|
|
11
|
+
* ()や符号に対応
|
|
12
|
+
* xなどの文字は未対応
|
|
13
|
+
* @param {string} x 計算式
|
|
14
|
+
*/
|
|
11
15
|
const calculatorCore = (x, ex) => {
|
|
16
|
+
//符号反転
|
|
12
17
|
x = x.replace(/--/g, '+');
|
|
13
18
|
x = x.replace(/\+\+/g, '+');
|
|
14
19
|
x = x.replace(/\+-/g, '+0-');
|
|
15
20
|
x = x.replace(/\-\+/g, '+0-');
|
|
16
|
-
|
|
21
|
+
//円計算
|
|
22
|
+
while (true) {
|
|
17
23
|
if (ex) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
for (const i in ex) {
|
|
25
|
+
if (x.indexOf(i) != -1) {
|
|
26
|
+
const $ = x.match(new RegExp(`\\${i}` + '([0-9]+)'));
|
|
27
|
+
if ($) {
|
|
28
|
+
x = x.replace($[0], (0, exchange_1.exchange)($[0], ex));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
21
31
|
}
|
|
22
32
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
//括弧の処理
|
|
34
|
+
if (x.indexOf('(') != -1 || x.indexOf(')') != -1) {
|
|
35
|
+
//括弧の中身をぬく
|
|
36
|
+
const y = x.match(/\(\d+\.?(\d+)?(\*|\/|\+|\-)\d+\.?(\d+)?\)/);
|
|
37
|
+
if (y) {
|
|
38
|
+
//括弧の中身を計算
|
|
39
|
+
x = x.replace(y[0], (0, exports.calculatorCore)(y[0].replace(/\(|\)/g, '')));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
x = x.replace(`(${x.slice(x.indexOf('(') + 1, x.indexOf(')'))})`, (0, exports.calculatorCore)(x.slice(x.indexOf('(') + 1, x.indexOf(')'))));
|
|
43
|
+
}
|
|
28
44
|
}
|
|
29
|
-
else
|
|
30
|
-
|
|
45
|
+
else if (x.indexOf('^') != -1 ||
|
|
46
|
+
x.indexOf('*') != -1 ||
|
|
47
|
+
x.indexOf('/') != -1) {
|
|
48
|
+
//掛け算と割り算の処理
|
|
49
|
+
const y = [
|
|
50
|
+
x.match(/\d+\.?(\d+)?(\*|\/|\^)\d+\.?(\d+)?/),
|
|
51
|
+
[''],
|
|
52
|
+
];
|
|
53
|
+
if (y[0]) {
|
|
54
|
+
y[1] = y[0][0]
|
|
55
|
+
.split(/(\d+\.\d+)|(\d+)/g)
|
|
56
|
+
.filter((n) => {
|
|
57
|
+
return typeof n != 'undefined' && n != '';
|
|
58
|
+
});
|
|
59
|
+
x = x.replace(y[0][0], `${y[1][1] == '^'
|
|
60
|
+
? Math.pow(+y[1][0], +y[1][2])
|
|
61
|
+
: y[1][1] == '*'
|
|
62
|
+
? (0, multiplication_1.multiplication)(+y[1][0], +y[1][2])
|
|
63
|
+
: y[1][1] == '/'
|
|
64
|
+
? (0, division_1.division)(+y[1][0], +y[1][2])
|
|
65
|
+
: '0'}`);
|
|
66
|
+
}
|
|
31
67
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
? (0,
|
|
46
|
-
: '
|
|
68
|
+
else if (x.indexOf('+') != -1 || x.indexOf('-') != -1) {
|
|
69
|
+
//加算と減算の処理
|
|
70
|
+
let y = [
|
|
71
|
+
x.match(/\d+\.?(\d+)?(\+|\-)\d+\.?(\d+)?/),
|
|
72
|
+
[''],
|
|
73
|
+
];
|
|
74
|
+
if (y[0]) {
|
|
75
|
+
y[1] = y[0][0]
|
|
76
|
+
.split(/(\d+\.\d+)|(\d+)/g)
|
|
77
|
+
.filter((n) => {
|
|
78
|
+
return typeof n != 'undefined' && n !== '';
|
|
79
|
+
});
|
|
80
|
+
x = x.replace(y[0][0], `${y[1][1] == '+'
|
|
81
|
+
? (0, addition_1.addition)(Number(y[1][0]), Number(y[1][2]))
|
|
82
|
+
: y[1][1] == '-'
|
|
83
|
+
? (0, subtract_1.subtract)(Number(y[1][0]), Number(y[1][2]))
|
|
84
|
+
: '0'}`);
|
|
85
|
+
}
|
|
47
86
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
else if (x.indexOf('+') != -1 || x.indexOf('-') != -1) {
|
|
51
|
-
let y = [
|
|
52
|
-
x.match(/\d+\.?(\d+)?(\+|\-)\d+\.?(\d+)?/),
|
|
53
|
-
[''],
|
|
54
|
-
];
|
|
55
|
-
if (y[0]) {
|
|
56
|
-
y[1] = y[0][0].split(/(\d+\.\d+)|(\d+)/g).filter((n) => {
|
|
57
|
-
return typeof n != 'undefined' && n !== '';
|
|
58
|
-
});
|
|
59
|
-
return calculatorCore(x.replace(y[0][0], `${y[1][1] == '+'
|
|
60
|
-
? (0, addition_1.default)(Number(y[1][0]), Number(y[1][2]))
|
|
61
|
-
: y[1][1] == '-'
|
|
62
|
-
? (0, subtract_1.default)(Number(y[1][0]), Number(y[1][2]))
|
|
63
|
-
: '0'}`), ex);
|
|
87
|
+
else {
|
|
88
|
+
return x;
|
|
64
89
|
}
|
|
65
|
-
return x;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
return x;
|
|
69
90
|
}
|
|
70
91
|
};
|
|
71
|
-
exports.
|
|
92
|
+
exports.calculatorCore = calculatorCore;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
exports.exchange = void 0;
|
|
4
|
+
const isNumber_1 = require("../isNumber");
|
|
5
|
+
const multiplication_1 = require("../multiplication");
|
|
6
|
+
const exchange = (n, props) => {
|
|
7
|
+
if (props) {
|
|
8
|
+
for (const i in props) {
|
|
9
|
+
if (n[0] == i) {
|
|
10
|
+
if ((0, isNumber_1.isNumber)(props[i])) {
|
|
11
|
+
return String((0, multiplication_1.multiplication)(Number(n.slice(1)), Number(props[i])));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
14
17
|
}
|
|
18
|
+
return n;
|
|
15
19
|
}
|
|
16
20
|
else {
|
|
17
21
|
return n;
|
|
18
22
|
}
|
|
19
23
|
};
|
|
20
|
-
exports.
|
|
24
|
+
exports.exchange = exchange;
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
* ()や符号に対応
|
|
4
4
|
* 一文字までの方程式に対応
|
|
5
5
|
* @param {string} x
|
|
6
|
+
* @param {object} ex 為替
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
$?: number;
|
|
9
|
-
}
|
|
10
|
-
declare const calculator: (x: string, ex?: Props) => string;
|
|
11
|
-
export default calculator;
|
|
8
|
+
export declare const calculator: <T extends object>(x: string, ex?: T | undefined) => string;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const
|
|
3
|
+
exports.calculator = void 0;
|
|
4
|
+
const core_1 = require("./core");
|
|
5
|
+
const literalExpression_1 = require("./literalExpression");
|
|
6
|
+
/**
|
|
7
|
+
* 電卓
|
|
8
|
+
* ()や符号に対応
|
|
9
|
+
* 一文字までの方程式に対応
|
|
10
|
+
* @param {string} x
|
|
11
|
+
* @param {object} ex 為替
|
|
12
|
+
*/
|
|
8
13
|
const calculator = (x, ex) => {
|
|
9
14
|
x = x.replace(/\s+/g, '');
|
|
10
15
|
if (x.indexOf('=') != -1) {
|
|
11
|
-
return (0, literalExpression_1.
|
|
16
|
+
return (0, literalExpression_1.literalExpression)(x);
|
|
12
17
|
}
|
|
13
18
|
else {
|
|
14
|
-
return (0, core_1.
|
|
19
|
+
return (0, core_1.calculatorCore)(x, ex);
|
|
15
20
|
}
|
|
16
21
|
};
|
|
17
|
-
exports.
|
|
22
|
+
exports.calculator = calculator;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
3
|
+
exports.literalExpression = void 0;
|
|
4
|
+
const division_1 = require("../division");
|
|
5
|
+
const gcd_1 = require("../gcd");
|
|
6
|
+
const core_1 = require("./core");
|
|
9
7
|
/**
|
|
8
|
+
* 方程式計算
|
|
10
9
|
* @param {string} x
|
|
11
10
|
*/
|
|
12
11
|
const literalExpression = (x) => {
|
|
@@ -22,6 +21,7 @@ const literalExpression = (x) => {
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
if (cache[0][1]) {
|
|
24
|
+
cache[0][1] = (0, core_1.calculatorCore)(cache[0][1]);
|
|
25
25
|
if (cache[0][1].indexOf('+') !== -1) {
|
|
26
26
|
cache[0][1] = cache[0][1].replace(/\+/g, 'plus');
|
|
27
27
|
}
|
|
@@ -36,15 +36,22 @@ const literalExpression = (x) => {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
cache[1] = cache[0][1]
|
|
39
|
-
? (0, core_1.
|
|
40
|
-
: (0, core_1.
|
|
39
|
+
? (0, core_1.calculatorCore)(`${cache[1]}${cache[0][1]}`)
|
|
40
|
+
: (0, core_1.calculatorCore)(cache[1]);
|
|
41
41
|
cache[0] = cache[0][0]
|
|
42
42
|
.split(/([0-9]+)|([a-zA-Z]+)/)
|
|
43
43
|
.filter((n) => n !== '' && typeof n != 'undefined');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (isNaN(Number(cache[0][0]))) {
|
|
45
|
+
return cache[1];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const cacheGcd = (0, gcd_1.gcd)(Number(cache[0][0]), Number(cache[1]));
|
|
49
|
+
if (cacheGcd !== 1) {
|
|
50
|
+
return `${(0, division_1.division)(Number(cache[1]), cacheGcd)}/${(0, division_1.division)(Number(cache[0][0]), cacheGcd)}`;
|
|
51
|
+
}
|
|
52
|
+
return cache[0][0] == '1'
|
|
53
|
+
? `${cache[1]}/${cache[0][0]}`
|
|
54
|
+
: cache[1];
|
|
47
55
|
}
|
|
48
|
-
return `${Number(cache[1])}/${Number(cache[0][0])}`;
|
|
49
56
|
};
|
|
50
|
-
exports.
|
|
57
|
+
exports.literalExpression = literalExpression;
|
package/module/Math/degToRad.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.degToRad = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 角度をラジアンに変換
|
|
5
6
|
* @param {number} x
|
|
7
|
+
* @returns number
|
|
6
8
|
*/
|
|
7
9
|
const degToRad = (x) => {
|
|
8
10
|
return x * (Math.PI / 180);
|
|
9
11
|
};
|
|
10
|
-
exports.
|
|
12
|
+
exports.degToRad = degToRad;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deviationValue = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 偏差値を計算する
|
|
6
|
+
* @param {number} value
|
|
7
|
+
* @param {number} averageValue
|
|
8
|
+
* @param {number} standardDeviationValue
|
|
9
|
+
* @returns number
|
|
10
|
+
*/
|
|
11
|
+
const deviationValue = (value, averageValue, standardDeviationValue) => {
|
|
12
|
+
return (((value - averageValue) / standardDeviationValue) * 10 + 50);
|
|
13
|
+
};
|
|
14
|
+
exports.deviationValue = deviationValue;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
export interface DIVISION {
|
|
2
|
+
(x: number, y: number, isFloor?: true): number;
|
|
3
|
+
(x: number, y: number, isFloor?: false): number[];
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* 誤差のない割り算
|
|
3
7
|
* @param {number} x
|
|
4
8
|
* @param {number} y
|
|
9
|
+
* @param {boolean} [isFloor=true]
|
|
10
|
+
* @returns number
|
|
5
11
|
*/
|
|
6
|
-
declare const division:
|
|
7
|
-
export default division;
|
|
12
|
+
export declare const division: DIVISION;
|
package/module/Math/division.js
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
3
|
+
exports.division = void 0;
|
|
4
|
+
const getDecimalLength_1 = require("./getDecimalLength");
|
|
5
|
+
const valueSwap_1 = require("./valueSwap");
|
|
7
6
|
/**
|
|
8
7
|
* 誤差のない割り算
|
|
9
8
|
* @param {number} x
|
|
10
9
|
* @param {number} y
|
|
10
|
+
* @param {boolean} [isFloor=true]
|
|
11
|
+
* @returns number
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
const
|
|
13
|
+
exports.division = ((x, y, isFloor = true) => {
|
|
14
|
+
const [decimalLengthX, decimalLengthY] = (0, valueSwap_1.valueSwap)((0, getDecimalLength_1.getDecimalLength)(x), (0, getDecimalLength_1.getDecimalLength)(y));
|
|
15
|
+
const n = decimalLengthX == decimalLengthY
|
|
16
|
+
? 1
|
|
17
|
+
: Math.pow(10, decimalLengthY - decimalLengthX);
|
|
14
18
|
x = +(x + '').replace('.', '');
|
|
15
19
|
y = +(y + '').replace('.', '');
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
return isFloor
|
|
21
|
+
? x > y
|
|
22
|
+
? x / y / n
|
|
23
|
+
: (x / y) * n
|
|
24
|
+
: [
|
|
25
|
+
x > y ? (x - (x % y)) / y / n : ((x - (x % y)) / y) * n,
|
|
26
|
+
x % y,
|
|
27
|
+
];
|
|
28
|
+
// return isFloor ? x / y : [(x - (x % y)) / y, x % y];
|
|
29
|
+
});
|
package/module/Math/factorial.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.factorial = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 階乗
|
|
5
6
|
* @param {number} x
|
|
7
|
+
* @returns number
|
|
6
8
|
*/
|
|
7
9
|
const factorial = (x) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
let result = 1;
|
|
11
|
+
if (x !== 0) {
|
|
12
|
+
while (x > 1) {
|
|
13
|
+
result *= x;
|
|
14
|
+
x--;
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
|
-
return
|
|
17
|
+
return result;
|
|
12
18
|
};
|
|
13
|
-
exports.
|
|
19
|
+
exports.factorial = factorial;
|
package/module/Math/factorize.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.factorize = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 因数分解
|
|
5
6
|
* @param {number} n
|
|
7
|
+
* @returns number[]
|
|
6
8
|
*/
|
|
7
9
|
const factorize = (n) => {
|
|
8
10
|
const result = [];
|
|
@@ -14,4 +16,4 @@ const factorize = (n) => {
|
|
|
14
16
|
}
|
|
15
17
|
return result;
|
|
16
18
|
};
|
|
17
|
-
exports.
|
|
19
|
+
exports.factorize = factorize;
|
package/module/Math/gcd.d.ts
CHANGED
package/module/Math/gcd.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
3
|
+
exports.gcd = void 0;
|
|
4
|
+
const valueSwap_1 = require("./valueSwap");
|
|
7
5
|
/**
|
|
8
6
|
* 自然数の最大公約数
|
|
9
7
|
* @param {number} x
|
|
10
8
|
* @param {number} y
|
|
11
9
|
* @param {number} ...z
|
|
10
|
+
* @returns number
|
|
12
11
|
*/
|
|
13
12
|
const gcd = (x, y, ...z) => {
|
|
14
13
|
if (x === 0 || y === 0)
|
|
15
14
|
return 0;
|
|
16
|
-
[x, y] = (0, valueSwap_1.
|
|
15
|
+
[x, y] = (0, valueSwap_1.valueSwap)(x, y);
|
|
17
16
|
/* ユークリッドの互除法 */
|
|
18
17
|
let r = y % x;
|
|
19
18
|
while (r !== 0) {
|
|
@@ -23,9 +22,9 @@ const gcd = (x, y, ...z) => {
|
|
|
23
22
|
}
|
|
24
23
|
if (z.length > 0) {
|
|
25
24
|
for (let i = 0; i < z.length; i++) {
|
|
26
|
-
x = gcd(x, z[i]);
|
|
25
|
+
x = (0, exports.gcd)(x, z[i]);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
return x;
|
|
30
29
|
};
|
|
31
|
-
exports.
|
|
30
|
+
exports.gcd = gcd;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDecimalLength = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* 小数点以下の桁数
|
|
5
6
|
* @param {number} value
|
|
7
|
+
* @returns number
|
|
6
8
|
*/
|
|
7
9
|
const getDecimalLength = (value) => {
|
|
8
10
|
let x = (value + '').split('.')[1];
|
|
@@ -11,4 +13,4 @@ const getDecimalLength = (value) => {
|
|
|
11
13
|
}
|
|
12
14
|
return 0;
|
|
13
15
|
};
|
|
14
|
-
exports.
|
|
16
|
+
exports.getDecimalLength = getDecimalLength;
|