mm_maths 1.1.9 → 1.2.1

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.
Files changed (305) hide show
  1. package/README.md +156 -0
  2. package/index.js +6 -410
  3. package/lib/maths.js +429 -0
  4. package/package.json +42 -33
  5. package/tool/math/index.js +83 -0
  6. package/tool/math/tool.json +60 -0
  7. package/.gitattributes +0 -5
  8. package/convert/format_multiply/index.js +0 -40
  9. package/convert/format_multiply/test.js +0 -5
  10. package/convert/format_plus/index.js +0 -42
  11. package/convert/format_plus/test.js +0 -4
  12. package/convert/four_run/convert.json +0 -8
  13. package/convert/four_run/index.js +0 -20
  14. package/convert/four_run/test.js +0 -7
  15. package/convert/multiply_divide/index.js +0 -197
  16. package/convert/multiply_divide/test.js +0 -14
  17. package/convert/plus_subtract/index.js +0 -160
  18. package/convert/plus_subtract/test.js +0 -15
  19. package/convert/readme.md +0 -2
  20. package/doc/mm_math.doc +0 -0
  21. package/doc//345/207/275/346/225/260/347/254/246/345/217/267/344/270/200/350/247/210/350/241/250.xls +0 -0
  22. package/express/README.md +0 -2
  23. package/identities/chemistry/readme.md +0 -1
  24. package/identities/equation/readme.md +0 -2
  25. package/identities/geometry/readme.md +0 -1
  26. package/identities/geometry/rectangle/readme.md +0 -1
  27. package/identities/geometry/string/readme.md +0 -1
  28. package/identities/physics/readme.md +0 -1
  29. package/identities/readme.md +0 -2
  30. package/math/array/average/index.js +0 -10
  31. package/math/array/average/math.json +0 -8
  32. package/math/array/average/test.js +0 -3
  33. package/math/array/col/index.js +0 -17
  34. package/math/array/col/math.json +0 -8
  35. package/math/array/col/test.js +0 -4
  36. package/math/array/composite/index.js +0 -35
  37. package/math/array/composite/math.json +0 -8
  38. package/math/array/composite/test.js +0 -4
  39. package/math/array/deviations/index.js +0 -15
  40. package/math/array/deviations/math.json +0 -8
  41. package/math/array/deviations/test.js +0 -3
  42. package/math/array/difference/index.js +0 -9
  43. package/math/array/difference/math.json +0 -8
  44. package/math/array/difference/test.js +0 -7
  45. package/math/array/distinct/index.js +0 -20
  46. package/math/array/distinct/math.json +0 -8
  47. package/math/array/distinct/test.js +0 -8
  48. package/math/array/distributive/index.js +0 -24
  49. package/math/array/distributive/math.json +0 -8
  50. package/math/array/distributive/test.js +0 -3
  51. package/math/array/divisor/index.js +0 -17
  52. package/math/array/divisor/math.json +0 -8
  53. package/math/array/divisor/test.js +0 -6
  54. package/math/array/intersect/index.js +0 -9
  55. package/math/array/intersect/math.json +0 -8
  56. package/math/array/intersect/test.js +0 -7
  57. package/math/array/max/index.js +0 -17
  58. package/math/array/max/math.json +0 -8
  59. package/math/array/max/test.js +0 -8
  60. package/math/array/median/index.js +0 -34
  61. package/math/array/median/math.json +0 -8
  62. package/math/array/median/test.js +0 -4
  63. package/math/array/min/index.js +0 -16
  64. package/math/array/min/math.json +0 -8
  65. package/math/array/min/test.js +0 -8
  66. package/math/array/multiple/index.js +0 -17
  67. package/math/array/multiple/math.json +0 -8
  68. package/math/array/multiple/test.js +0 -7
  69. package/math/array/natural/index.js +0 -17
  70. package/math/array/natural/math.json +0 -8
  71. package/math/array/natural/test.js +0 -9
  72. package/math/array/pos/index.js +0 -21
  73. package/math/array/pos/math.json +0 -8
  74. package/math/array/pos/test.js +0 -41
  75. package/math/array/prime/index.js +0 -35
  76. package/math/array/prime/math.json +0 -8
  77. package/math/array/prime/test.js +0 -4
  78. package/math/array/readme.md +0 -5
  79. package/math/array/reduction/index.js +0 -57
  80. package/math/array/reduction/math.json +0 -8
  81. package/math/array/reduction/test.js +0 -42
  82. package/math/array/rising/index.js +0 -8
  83. package/math/array/rising/math.json +0 -8
  84. package/math/array/rising/test.js +0 -3
  85. package/math/array/row/index.js +0 -11
  86. package/math/array/row/math.json +0 -8
  87. package/math/array/row/test.js +0 -4
  88. package/math/array/square/index.js +0 -12
  89. package/math/array/square/math.json +0 -8
  90. package/math/array/square/test.js +0 -3
  91. package/math/array/stddev/index.js +0 -17
  92. package/math/array/stddev/math.json +0 -8
  93. package/math/array/stddev/test.js +0 -4
  94. package/math/array/sum/index.js +0 -13
  95. package/math/array/sum/math.json +0 -8
  96. package/math/array/sum/test.js +0 -3
  97. package/math/array/sumproduct/index.js +0 -13
  98. package/math/array/sumproduct/math.json +0 -8
  99. package/math/array/sumproduct/test.js +0 -3
  100. package/math/array/union/index.js +0 -11
  101. package/math/array/union/math.json +0 -8
  102. package/math/array/union/test.js +0 -7
  103. package/math/base/abs/index.js +0 -8
  104. package/math/base/abs/math.json +0 -8
  105. package/math/base/abs/test.js +0 -3
  106. package/math/base/ceil/index.js +0 -8
  107. package/math/base/ceil/math.json +0 -8
  108. package/math/base/ceil/test.js +0 -3
  109. package/math/base/denominator/index.js +0 -17
  110. package/math/base/denominator/math.json +0 -9
  111. package/math/base/denominator/test.js +0 -3
  112. package/math/base/diff/index.js +0 -9
  113. package/math/base/diff/math.json +0 -8
  114. package/math/base/diff/test.js +0 -6
  115. package/math/base/exp/index.js +0 -8
  116. package/math/base/exp/math.json +0 -8
  117. package/math/base/exp/test.js +0 -6
  118. package/math/base/floor/index.js +0 -8
  119. package/math/base/floor/math.json +0 -8
  120. package/math/base/floor/test.js +0 -3
  121. package/math/base/int/index.js +0 -8
  122. package/math/base/int/math.json +0 -8
  123. package/math/base/int/test.js +0 -2
  124. package/math/base/log/index.js +0 -8
  125. package/math/base/log/math.json +0 -8
  126. package/math/base/log/test.js +0 -4
  127. package/math/base/max_divisor/index.js +0 -10
  128. package/math/base/max_divisor/math.json +0 -9
  129. package/math/base/max_divisor/test.js +0 -3
  130. package/math/base/min_multiple/index.js +0 -11
  131. package/math/base/min_multiple/math.json +0 -9
  132. package/math/base/min_multiple/test.js +0 -3
  133. package/math/base/mod/index.js +0 -8
  134. package/math/base/mod/math.json +0 -8
  135. package/math/base/mod/test.js +0 -3
  136. package/math/base/pow/index.js +0 -9
  137. package/math/base/pow/math.json +0 -8
  138. package/math/base/pow/test.js +0 -3
  139. package/math/base/rand/index.js +0 -21
  140. package/math/base/rand/math.json +0 -8
  141. package/math/base/rand/test.js +0 -3
  142. package/math/base/random/index.js +0 -12
  143. package/math/base/random/math.json +0 -8
  144. package/math/base/random/test.js +0 -4
  145. package/math/base/readme.md +0 -1
  146. package/math/base/round/index.js +0 -14
  147. package/math/base/round/math.json +0 -8
  148. package/math/base/round/test.js +0 -4
  149. package/math/base/sqrt/index.js +0 -8
  150. package/math/base/sqrt/math.json +0 -8
  151. package/math/base/sqrt/test.js +0 -5
  152. package/math/readme.md +0 -1
  153. package/math/stock/AMOUNT/index.js +0 -7
  154. package/math/stock/AMOUNT/math.json +0 -8
  155. package/math/stock/AMOUNT/test.js +0 -4
  156. package/math/stock/AP/index.js +0 -20
  157. package/math/stock/AP/math.json +0 -8
  158. package/math/stock/AP/test.js +0 -5
  159. package/math/stock/AROON/index.js +0 -14
  160. package/math/stock/ARR/index.js +0 -10
  161. package/math/stock/ARR/math.json +0 -8
  162. package/math/stock/ARR/test.js +0 -45
  163. package/math/stock/ASTAR/index.js +0 -20
  164. package/math/stock/ASTAR/math.json +0 -8
  165. package/math/stock/ASTAR/test.js +0 -4
  166. package/math/stock/AVERAGE/index.js +0 -14
  167. package/math/stock/AVERAGE/math.json +0 -8
  168. package/math/stock/AVERAGE/test.js +0 -5
  169. package/math/stock/AYANG/index.js +0 -18
  170. package/math/stock/AYANG/math.json +0 -8
  171. package/math/stock/AYANG/test.js +0 -4
  172. package/math/stock/AYIN/index.js +0 -18
  173. package/math/stock/AYIN/math.json +0 -8
  174. package/math/stock/AYIN/test.js +0 -4
  175. package/math/stock/BBANDS/index.js +0 -0
  176. package/math/stock/BETWEEN/index.js +0 -24
  177. package/math/stock/BETWEEN/math.json +0 -8
  178. package/math/stock/BETWEEN/test.js +0 -4
  179. package/math/stock/CLOSE/c.js +0 -0
  180. package/math/stock/CLOSE/index.js +0 -11
  181. package/math/stock/CLOSE/math.json +0 -8
  182. package/math/stock/CLOSE/test.js +0 -45
  183. package/math/stock/CP/index.js +0 -35
  184. package/math/stock/CP/math.json +0 -8
  185. package/math/stock/CP/test.js +0 -5
  186. package/math/stock/CROSS/index.js +0 -29
  187. package/math/stock/CROSS/math.json +0 -8
  188. package/math/stock/CROSS/test.js +0 -6
  189. package/math/stock/DATE/index.js +0 -14
  190. package/math/stock/DATE/math.json +0 -8
  191. package/math/stock/DATE/test.js +0 -45
  192. package/math/stock/DOWN/index.js +0 -19
  193. package/math/stock/DOWN/math.json +0 -8
  194. package/math/stock/DOWN/test.js +0 -8
  195. package/math/stock/DOWNNDAY/index.js +0 -27
  196. package/math/stock/DOWNNDAY/math.json +0 -8
  197. package/math/stock/DOWNNDAY/test.js +0 -10
  198. package/math/stock/EMA/index.js +0 -30
  199. package/math/stock/EMA/math.json +0 -8
  200. package/math/stock/EMA/test.js +0 -4
  201. package/math/stock/HHV/index.js +0 -16
  202. package/math/stock/HHV/math.json +0 -8
  203. package/math/stock/HHV/test.js +0 -4
  204. package/math/stock/HIGH/h.js +0 -0
  205. package/math/stock/HIGH/index.js +0 -11
  206. package/math/stock/HIGH/math.json +0 -8
  207. package/math/stock/HIGH/test.js +0 -45
  208. package/math/stock/LEFT/index.js +0 -13
  209. package/math/stock/LEFT/math.json +0 -8
  210. package/math/stock/LEFT/test.js +0 -4
  211. package/math/stock/LLV/index.js +0 -16
  212. package/math/stock/LLV/math.json +0 -8
  213. package/math/stock/LLV/test.js +0 -4
  214. package/math/stock/LOW/index.js +0 -11
  215. package/math/stock/LOW/l.js +0 -0
  216. package/math/stock/LOW/math.json +0 -8
  217. package/math/stock/LOW/test.js +0 -47
  218. package/math/stock/MA/index.js +0 -30
  219. package/math/stock/MA/math.json +0 -8
  220. package/math/stock/MA/test.js +0 -5
  221. package/math/stock/MACD/index.js +0 -29
  222. package/math/stock/MACD/math.json +0 -8
  223. package/math/stock/MACD/test.js +0 -4
  224. package/math/stock/MFI/index.js +0 -33
  225. package/math/stock/NMA/index.js +0 -23
  226. package/math/stock/NMA/math.json +0 -8
  227. package/math/stock/NMA/test.js +0 -5
  228. package/math/stock/NOT/index.js +0 -7
  229. package/math/stock/NOT/math.json +0 -8
  230. package/math/stock/NOT/test.js +0 -10
  231. package/math/stock/OPEN/index.js +0 -11
  232. package/math/stock/OPEN/math.json +0 -8
  233. package/math/stock/OPEN/o.js +0 -0
  234. package/math/stock/OPEN/test.js +0 -45
  235. package/math/stock/PERCPRICEOSC/index.js +0 -19
  236. package/math/stock/REF/index.js +0 -15
  237. package/math/stock/REF/math.json +0 -8
  238. package/math/stock/REF/test.js +0 -5
  239. package/math/stock/RIGHT/index.js +0 -13
  240. package/math/stock/RIGHT/math.json +0 -8
  241. package/math/stock/RIGHT/test.js +0 -4
  242. package/math/stock/RSI/index.js +0 -36
  243. package/math/stock/SMA/index.js +0 -12
  244. package/math/stock/STAR/index.js +0 -19
  245. package/math/stock/STAR/math.json +0 -8
  246. package/math/stock/STAR/test.js +0 -4
  247. package/math/stock/STOCHRSI/index.js +0 -19
  248. package/math/stock/SUM/index.js +0 -19
  249. package/math/stock/SUM/math.json +0 -8
  250. package/math/stock/SUM/test.js +0 -7
  251. package/math/stock/TIME/index.js +0 -14
  252. package/math/stock/TIME/math.json +0 -8
  253. package/math/stock/TIME/test.js +0 -45
  254. package/math/stock/TRUERANGE/index.js +0 -19
  255. package/math/stock/UP/index.js +0 -19
  256. package/math/stock/UP/math.json +0 -8
  257. package/math/stock/UP/test.js +0 -9
  258. package/math/stock/UPNDAY/index.js +0 -28
  259. package/math/stock/UPNDAY/math.json +0 -8
  260. package/math/stock/UPNDAY/test.js +0 -10
  261. package/math/stock/VMA/index.js +0 -41
  262. package/math/stock/VMA/math.json +0 -8
  263. package/math/stock/VMA/test.js +0 -7
  264. package/math/stock/VOL/index.js +0 -11
  265. package/math/stock/VOL/math.json +0 -8
  266. package/math/stock/VOL/test.js +0 -45
  267. package/math/stock/WILLR/index.js +0 -22
  268. package/math/stock/YANG/index.js +0 -16
  269. package/math/stock/YANG/math.json +0 -8
  270. package/math/stock/YANG/test.js +0 -4
  271. package/math/stock/YIN/index.js +0 -16
  272. package/math/stock/YIN/math.json +0 -8
  273. package/math/stock/YIN/test.js +0 -4
  274. package/math/stock/readme.md +0 -294
  275. package/math/trigonometric/cos/index.js +0 -8
  276. package/math/trigonometric/cos/math.json +0 -20
  277. package/math/trigonometric/cot/index.js +0 -8
  278. package/math/trigonometric/cot/math.json +0 -17
  279. package/math/trigonometric/csc/index.js +0 -8
  280. package/math/trigonometric/csc/math.json +0 -20
  281. package/math/trigonometric/readme.md +0 -2
  282. package/math/trigonometric/sec/index.js +0 -8
  283. package/math/trigonometric/sec/math.json +0 -20
  284. package/math/trigonometric/sin/index.js +0 -8
  285. package/math/trigonometric/sin/math.json +0 -20
  286. package/math/trigonometric/tan/index.js +0 -8
  287. package/math/trigonometric/tan/math.json +0 -18
  288. package/symbol/brackets/index.js +0 -46
  289. package/symbol/brackets/symbol.json +0 -8
  290. package/symbol/brackets/test.js +0 -12
  291. package/symbol/decimal/index.js +0 -41
  292. package/symbol/decimal/symbol.json +0 -8
  293. package/symbol/decimal/test.js +0 -2
  294. package/symbol/percentage/index.js +0 -48
  295. package/symbol/percentage/symbol.json +0 -8
  296. package/symbol/percentage/test.js +0 -2
  297. package/symbol/pi/index.js +0 -20
  298. package/symbol/pi/symbol.json +0 -9
  299. package/symbol/pi/test.js +0 -2
  300. package/symbol/power/index.js +0 -111
  301. package/symbol/power/symbol.json +0 -8
  302. package/symbol/power/test.js +0 -10
  303. package/symbol/readme.md +0 -2
  304. package/test.js +0 -32
  305. package/test2.js +0 -47
@@ -1,8 +0,0 @@
1
- {
2
- "key": "square",
3
- "name": "square",
4
- "title": "求数组成员的平方",
5
- "group": "array",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const square = require('./index');
2
- console.log(square ([1, 2, 3, 4, 5]));
3
- console.log(square ([2, 3, 5, 7]));
@@ -1,17 +0,0 @@
1
- const square = require('../square');
2
- const sum = require('../sum');
3
-
4
- /**
5
- * 求标准差
6
- * @param {Array} arr 数组
7
- * @return {Number} 返回平均值
8
- */
9
- module.exports = function stddev(arr) {
10
- // 先求每个数的平方
11
- var ar = square(arr);
12
- // 然后将平方相加
13
- var value = sum(ar);
14
-
15
- // 再除以数量开平方
16
- return Math.sqrt(value / (arr.length - 1));
17
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "stddev",
3
- "name": "stddev",
4
- "title": "求标准差",
5
- "group": "array",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const stddev = require('./index');
2
- console.log(stddev([1, 2, 3, 4, 5]));
3
- console.log(stddev([2, 4, 6, 8, 16]));
4
- console.log(stddev([21, 37, 25, 36, 23.5]));
@@ -1,13 +0,0 @@
1
- /**
2
- * 求数组之和
3
- * @param {Array} arr 数组
4
- * @return {Number} 返回数值
5
- */
6
- module.exports = function sum(arr) {
7
- var num = 0;
8
- var len = arr.length;
9
- for (var i = 0; i < len; i++) {
10
- num += arr[i];
11
- }
12
- return num;
13
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "sum",
3
- "name": "summation",
4
- "title": "求和",
5
- "group": "fraction",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const sum = require('./index');
2
- console.log(sum([4, 18, 16, 8]));
3
- console.log(sum([1, 2, 3, 4]));
@@ -1,13 +0,0 @@
1
- /**
2
- * 求数组之和
3
- * @param {Array} arr 数组
4
- * @return {Number} 返回数值
5
- */
6
- module.exports = function sumproduct(arr) {
7
- var num = 1;
8
- var len = arr.length;
9
- for (var i = 0; i < len; i++) {
10
- num *= arr[i];
11
- }
12
- return num;
13
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "sumproduct",
3
- "name": "sumproduct",
4
- "title": "求数组乘积",
5
- "group": "fraction",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const sumproduct = require('./index');
2
- console.log(sumproduct([4, 18, 16, 8]));
3
- console.log(sumproduct([1, 2, 3, 4]));
@@ -1,11 +0,0 @@
1
- /**
2
- * 并集
3
- * @param {Array} arr_1 数组1
4
- * @param {Array} arr_2 数组2
5
- * @return {Array} 返回合并后的数组
6
- */
7
- module.exports = function union(arr_1, arr_2) {
8
- return arr_1.concat(arr_2.filter(function(v) {
9
- return arr_1.indexOf(v) === -1
10
- }));
11
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "union",
3
- "name": "union",
4
- "title": "并集",
5
- "group": "fraction",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,7 +0,0 @@
1
- const union = require('./index');
2
- var arr = [15, 35, 68, 66];
3
- var arr_2 = [38, 35, 68];
4
- var arr_3 = [25, 35, 22, 33];
5
-
6
- console.log(union(arr, arr_2));
7
- console.log(union(arr, arr_3));
@@ -1,8 +0,0 @@
1
- /**
2
- * 取绝对值
3
- * @param {String} value 数值
4
- * @return {Number} 返回绝对值
5
- */
6
- module.exports = function abs(value) {
7
- return Math.abs(value);
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "abs",
3
- "name": "absolute value",
4
- "title": "绝对值",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const abs = require('./index');
2
- console.log(abs(-7.25));
3
- console.log(abs(3.25));
@@ -1,8 +0,0 @@
1
- /**
2
- * 向上取整数
3
- * @param {String} value 数值
4
- * @return {Number} 返回整数
5
- */
6
- module.exports = function ceil(value) {
7
- return Math.ceil(value);
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "ceil",
3
- "name": "ceil",
4
- "title": "向上取整",
5
- "group": "fraction",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const ceil = require('./index');
2
- console.log(ceil(4.15268));
3
- console.log(ceil(3.1415926));
@@ -1,17 +0,0 @@
1
- const max_divisor = require('../max_divisor');
2
-
3
- /**
4
- * 通分母
5
- * @param {Object} multiply
6
- * @param {Object} divide
7
- * @return {Object} 返回最小分子分母
8
- */
9
- module.exports = function denominator(multiply, divide) {
10
- var num = max_divisor(multiply, divide);
11
- multiply = multiply / num;
12
- divide = divide / num;
13
- return {
14
- multiply,
15
- divide
16
- }
17
- };
@@ -1,9 +0,0 @@
1
- {
2
- "symbol": "/",
3
- "key": "denominator",
4
- "name": "common denominator",
5
- "title": "通分母",
6
- "group": "fraction",
7
- "type": "base",
8
- "func_file": "./index.js"
9
- }
@@ -1,3 +0,0 @@
1
- const denominator = require('./index');
2
- console.log(denominator(4, 18));
3
- console.log(denominator(5, 10));
@@ -1,9 +0,0 @@
1
- /**
2
- * 微分
3
- * @param {Number} x 数值1
4
- * @param {Number} y 数值2
5
- * @return {Number} 返回微分后数值
6
- */
7
- module.exports = function diff(x, y) {
8
- return ((x - y) / ((x + y) / 2)) * 100;
9
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "diff",
3
- "name": "differential",
4
- "title": "微分",
5
- "group": "fraction",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,6 +0,0 @@
1
- const diff = require('./index');
2
- console.log(diff(4, 4));
3
- console.log(diff(100, 10));
4
- console.log(diff(10, 25));
5
- console.log(diff(2, 4));
6
- console.log(diff(1, 2));
@@ -1,8 +0,0 @@
1
- /**
2
- * 取指数
3
- * @param {String} value 数值
4
- * @return {Number} 返回指数
5
- */
6
- module.exports = function exp(value) {
7
- return Math.exp(value);
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "exp",
3
- "name": "index number",
4
- "title": "指数",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,6 +0,0 @@
1
- const exp = require('./index');
2
- console.log(exp(4));
3
- console.log(exp(100));
4
- console.log(exp(10));
5
- console.log(exp(2));
6
- console.log(exp(1));
@@ -1,8 +0,0 @@
1
- /**
2
- * 向下取整数
3
- * @param {String} value 数值
4
- * @return {Number} 返回整数
5
- */
6
- module.exports = function floor(value) {
7
- return Math.floor(value);
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "floor",
3
- "name": "floor",
4
- "title": "向下取整",
5
- "group": "fraction",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const floor = require('./index');
2
- console.log(floor(4.16546));
3
- console.log(floor(4.9553));
@@ -1,8 +0,0 @@
1
- /**
2
- * 取整数
3
- * @param {String} value 数值
4
- * @return {Number} 返回整数
5
- */
6
- module.exports = function int(value) {
7
- return parseInt(value);
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "int",
3
- "name": "integer",
4
- "title": "整数",
5
- "group": "fraction",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,2 +0,0 @@
1
- const int = require('./index');
2
- console.log(int(4.255646));
@@ -1,8 +0,0 @@
1
- /**
2
- * 底数
3
- * @param {String} value 数值
4
- * @return {Number} 返回底数
5
- */
6
- module.exports = function log(value) {
7
- return Math.log(value);
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "log",
3
- "name": "logarithm",
4
- "title": "对数",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const log = require('./index');
2
- console.log(log(4));
3
- console.log(log(64));
4
- console.log(log(100));
@@ -1,10 +0,0 @@
1
- /**
2
- * 最大公约数
3
- * @param {number} a 值
4
- * @param {number} b 值
5
- * @return {number} 返回公约数
6
- */
7
- function max_divisor(a, b) {
8
- return b === 0 ? a : max_divisor(b, a % b);
9
- }
10
- module.exports = max_divisor;
@@ -1,9 +0,0 @@
1
- {
2
- "symbol": "~",
3
- "key": "max_divisor",
4
- "name": "max common divisor",
5
- "title": "最大公约数",
6
- "group": "fraction",
7
- "type": "base",
8
- "func_file": "./index.js"
9
- }
@@ -1,3 +0,0 @@
1
- const max_divisor = require('./index');
2
- console.log(max_divisor(4,18));
3
- console.log(max_divisor(4,16));
@@ -1,11 +0,0 @@
1
- const max_divisor = require('../max_divisor');
2
-
3
- /**
4
- * 最小公倍数
5
- * @param {number} a 值
6
- * @param {number} b 值
7
- * @return {number} 返回公倍数
8
- */
9
- module.exports = function min_multiple(a, b) {
10
- return (a * b) / max_divisor(a, b);
11
- };
@@ -1,9 +0,0 @@
1
- {
2
- "symbol": "~",
3
- "key": "min_multiple",
4
- "name": "min common multiple",
5
- "title": "最小公倍数",
6
- "group": "fraction",
7
- "type": "base",
8
- "func_file": "./index.js"
9
- }
@@ -1,3 +0,0 @@
1
- const min_multiple = require('./index');
2
- console.log(min_multiple(4,18));
3
- console.log(min_multiple(6,15));
@@ -1,8 +0,0 @@
1
- /**
2
- * 取模(取余数)
3
- * @param {number} 值
4
- * @return {number} 返回公倍数
5
- */
6
- module.exports = function mod(a, b) {
7
- return a % b;
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "mod",
3
- "name": "delivery",
4
- "title": "取模(取余数)",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const mod = require('./index');
2
- console.log(mod(8, -3));
3
- console.log(mod(10, 3));
@@ -1,9 +0,0 @@
1
- /**
2
- * 幂次方
3
- * @param {number} a 值
4
- * @param {number} b 值
5
- * @return {number} 返回数值
6
- */
7
- module.exports = function pow(a, b) {
8
- return Math.pow(a, b);
9
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "pow",
3
- "name": "power",
4
- "title": "幂次方",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const pow = require('./index');
2
- console.log(pow(10,3));
3
- console.log(pow(2,4));
@@ -1,21 +0,0 @@
1
- /**
2
- * 随机数
3
- * @param {number} min 最小值
4
- * @param {number} max 最大值
5
- * @return {number} 返回数值
6
- */
7
- module.exports = function rand(min, max) {
8
- var num = 0;
9
- switch (arguments.length) {
10
- case 1:
11
- num = parseInt(Math.random() * min + 1, 10);
12
- break;
13
- case 2:
14
- num = parseInt(Math.random() * (max - min + 1) + min, 10);
15
- break;
16
- default:
17
- num = 0;
18
- break;
19
- }
20
- return num;
21
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "rand",
3
- "name": "rand",
4
- "title": "随机数函数",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,3 +0,0 @@
1
- const rand = require('./index');
2
- console.log(rand(3,10));
3
- console.log(rand(2,4));
@@ -1,12 +0,0 @@
1
- /**
2
- * 随机数
3
- * @param {number} n 取N倍内随机数, 例如 n=10,则取1-10, n=100则取1-100, 为空则取随机小数
4
- * @return {number} 返回数值
5
- */
6
- module.exports = function random(n) {
7
- if (n) {
8
- return Math.floor((Math.random() * n) + 1);
9
- } else {
10
- return Math.random();
11
- }
12
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "random",
3
- "name": "random",
4
- "title": "随机数",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const random = require('./index');
2
- console.log(random(4));
3
- console.log(random(10));
4
- console.log(random());
@@ -1 +0,0 @@
1
- # 基础计算函数
@@ -1,14 +0,0 @@
1
- /**
2
- * 四舍五入
3
- * @param {number} value 数值
4
- * @param {number} len 保留位数
5
- * @return {number} 返回数值
6
- */
7
- module.exports = function round(value, len) {
8
- if (len) {
9
- var n = Math.pow(10, len);
10
- return Math.round(value * n) / n;
11
- } else {
12
- return Math.round(value)
13
- }
14
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "round",
3
- "name": "round",
4
- "title": "四舍五入",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const round = require('./index');
2
- console.log(round(3.1415926, 4));
3
- console.log(round(3.1415926, 2));
4
- console.log(round(3.1415926));
@@ -1,8 +0,0 @@
1
- /**
2
- * 开平方根
3
- * @param {number} value 数值
4
- * @return {number} 返回数值
5
- */
6
- module.exports = function sqrt(value) {
7
- return Math.sqrt(value)
8
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "sqrt",
3
- "name": "square root",
4
- "title": "开平方根",
5
- "group": "default",
6
- "type": "base",
7
- "func_file": "./index.js"
8
- }
@@ -1,5 +0,0 @@
1
- const sqrt = require('./index');
2
- console.log(sqrt(4));
3
- console.log(sqrt(16));
4
- console.log(sqrt(100));
5
- console.log(sqrt(5));
package/math/readme.md DELETED
@@ -1 +0,0 @@
1
- # 计算函数库
@@ -1,7 +0,0 @@
1
- /**
2
- * 求数组成员个数
3
- * @param {Array} arr 数组
4
- */
5
- module.exports = function AMOUNT(arr) {
6
- return arr.length;
7
- }
@@ -1,8 +0,0 @@
1
- {
2
- "key": "AMOUNT",
3
- "name": "array length",
4
- "title": "求数组成员个数",
5
- "group": "number",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const AMOUNT = require('./index');
2
- console.log(AMOUNT([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]));
3
- console.log(AMOUNT([2, 4, 6, 8, 16, 2, 4, 6]));
4
- console.log(AMOUNT([21, 37, 25, 36, 30.5, 21, 37, 25, 36]));
@@ -1,20 +0,0 @@
1
- const AVERAGE = require('../AVERAGE');
2
-
3
- /**
4
- * 判断所有值是否在返回内
5
- * @param {Array} arr 数组
6
- * @param {Number} n 倍率
7
- * @return {Number} 返回整数 比较正确返回1, 否则返回0
8
- */
9
- module.exports = function AP(arr, n = 0) {
10
- var val = AVERAGE(arr);
11
- var t = 0;
12
- var len = arr.length;
13
- for (var i = 0; i < len; i++) {
14
- var v = arr[i];
15
- if (v <= val * (1 + n) && v >= val * (1 - n)) {
16
- t++;
17
- };
18
- }
19
- return arr.length === t
20
- };