math-exercises 1.3.12 → 1.3.13

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 (254) hide show
  1. package/README.md +73 -73
  2. package/lib/exercises/calcul/addAndSub.d.ts +6 -6
  3. package/lib/exercises/calcul/addAndSub.js +39 -39
  4. package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.d.ts +3 -3
  5. package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -35
  6. package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.d.ts +3 -3
  7. package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.js +32 -32
  8. package/lib/exercises/calcul/fractions/fractionAndIntegerSum.d.ts +3 -3
  9. package/lib/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -32
  10. package/lib/exercises/calcul/fractions/fractionsDivision.d.ts +3 -3
  11. package/lib/exercises/calcul/fractions/fractionsDivision.js +29 -29
  12. package/lib/exercises/calcul/fractions/fractionsProduct.d.ts +3 -3
  13. package/lib/exercises/calcul/fractions/fractionsProduct.js +28 -28
  14. package/lib/exercises/calcul/fractions/fractionsSum.d.ts +3 -3
  15. package/lib/exercises/calcul/fractions/fractionsSum.js +28 -28
  16. package/lib/exercises/calcul/fractions/simplifyFraction.d.ts +3 -3
  17. package/lib/exercises/calcul/fractions/simplifyFraction.js +24 -24
  18. package/lib/exercises/calcul/operations/operationsPriorities.d.ts +10 -10
  19. package/lib/exercises/calcul/operations/operationsPriorities.js +98 -98
  20. package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.js +111 -111
  21. package/lib/exercises/calcul/operationsPriorities.js +88 -88
  22. package/lib/exercises/calcul/rounding/rounding.d.ts +19 -19
  23. package/lib/exercises/calcul/rounding/rounding.js +85 -85
  24. package/lib/exercises/calculLitteral/distributivity/allIdentities.d.ts +3 -3
  25. package/lib/exercises/calculLitteral/distributivity/allIdentities.js +27 -27
  26. package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.d.ts +3 -3
  27. package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.js +30 -30
  28. package/lib/exercises/calculLitteral/distributivity/firstIdentity.d.ts +3 -3
  29. package/lib/exercises/calculLitteral/distributivity/firstIdentity.js +31 -31
  30. package/lib/exercises/calculLitteral/distributivity/secondIdentity.d.ts +3 -3
  31. package/lib/exercises/calculLitteral/distributivity/secondIdentity.js +32 -32
  32. package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.d.ts +3 -3
  33. package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.js +32 -32
  34. package/lib/exercises/calculLitteral/distributivity/thirdIdentity.d.ts +3 -3
  35. package/lib/exercises/calculLitteral/distributivity/thirdIdentity.js +31 -31
  36. package/lib/exercises/calculLitteral/equation/equationType1Exercise.d.ts +6 -6
  37. package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +37 -37
  38. package/lib/exercises/calculLitteral/equation/equationType2Exercise.d.ts +6 -6
  39. package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +40 -40
  40. package/lib/exercises/calculLitteral/equation/equationType3Exercise.d.ts +6 -6
  41. package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +41 -41
  42. package/lib/exercises/calculLitteral/equation/equationType4Exercise.d.ts +6 -6
  43. package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +43 -43
  44. package/lib/exercises/calculLitteral/factorisation/factoIdRmq1.d.ts +3 -3
  45. package/lib/exercises/calculLitteral/factorisation/factoIdRmq1.js +32 -32
  46. package/lib/exercises/calculLitteral/factorisation/factoIdRmq2.d.ts +3 -3
  47. package/lib/exercises/calculLitteral/factorisation/factoIdRmq2.js +33 -33
  48. package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.d.ts +3 -3
  49. package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.js +32 -32
  50. package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.d.ts +6 -6
  51. package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.js +38 -38
  52. package/lib/exercises/derivation/derivative/affineDerivative.d.ts +4 -0
  53. package/lib/exercises/derivation/derivative/affineDerivative.d.ts.map +1 -0
  54. package/lib/exercises/derivation/derivative/affineDerivative.js +27 -0
  55. package/lib/exercises/derivation/derivative/secondDegreeDerivative.d.ts +1 -0
  56. package/lib/exercises/derivation/derivative/secondDegreeDerivative.d.ts.map +1 -0
  57. package/lib/exercises/derivation/derivative/secondDegreeDerivative.js +28 -0
  58. package/lib/exercises/derivation/derivative/thridDegreeDerivative.d.ts +1 -0
  59. package/lib/exercises/derivation/derivative/thridDegreeDerivative.d.ts.map +1 -0
  60. package/lib/exercises/derivation/derivative/thridDegreeDerivative.js +1 -0
  61. package/lib/exercises/exercise.d.ts +16 -16
  62. package/lib/exercises/exercise.js +7 -7
  63. package/lib/exercises/exercises.d.ts +1 -1
  64. package/lib/exercises/exercises.js +113 -113
  65. package/lib/exercises/geometry/cartesian/midpoint.d.ts +3 -3
  66. package/lib/exercises/geometry/cartesian/midpoint.js +29 -29
  67. package/lib/exercises/geometry/vectors/scalarProductViaCoords.d.ts +3 -3
  68. package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +28 -28
  69. package/lib/exercises/geometry/vectors/scalarProductViaNorms.js +27 -27
  70. package/lib/exercises/powers/powersDivision.d.ts +7 -7
  71. package/lib/exercises/powers/powersDivision.js +44 -44
  72. package/lib/exercises/powers/powersOfTenToDecimal.d.ts +6 -6
  73. package/lib/exercises/powers/powersOfTenToDecimal.js +32 -32
  74. package/lib/exercises/powers/powersPower.d.ts +7 -7
  75. package/lib/exercises/powers/powersPower.js +43 -43
  76. package/lib/exercises/powers/powersProduct.d.ts +7 -7
  77. package/lib/exercises/powers/powersProduct.js +44 -44
  78. package/lib/exercises/powers/scientificToDecimal.d.ts +6 -6
  79. package/lib/exercises/powers/scientificToDecimal.js +37 -37
  80. package/lib/exercises/sequences/geometric/geometricExplicitFormulaUsage.d.ts +3 -3
  81. package/lib/exercises/sequences/geometric/geometricExplicitFormulaUsage.js +34 -34
  82. package/lib/exercises/sequences/geometric/geometricFindExplicitFormula.d.ts +3 -3
  83. package/lib/exercises/sequences/geometric/geometricFindExplicitFormula.js +33 -33
  84. package/lib/exercises/sequences/geometric/geometricFindReason.d.ts +3 -3
  85. package/lib/exercises/sequences/geometric/geometricFindReason.js +29 -29
  86. package/lib/exercises/sequences/geometric/geometricReasonUsage.d.ts +3 -3
  87. package/lib/exercises/sequences/geometric/geometricReasonUsage.js +28 -28
  88. package/lib/exercises/sequences/geometric/geometricRecurrenceFormulaUsage.d.ts +7 -7
  89. package/lib/exercises/sequences/geometric/geometricRecurrenceFormulaUsage.js +28 -28
  90. package/lib/exercises/squareRoots/simpifySquareRoot.d.ts +3 -3
  91. package/lib/exercises/squareRoots/simpifySquareRoot.js +27 -27
  92. package/lib/exercises/trigonometry/mainRemarkableValues.d.ts +3 -3
  93. package/lib/exercises/trigonometry/mainRemarkableValues.js +28 -28
  94. package/lib/exercises/trigonometry/remarkableValues.d.ts +3 -3
  95. package/lib/exercises/trigonometry/remarkableValues.js +28 -28
  96. package/lib/exercises/utils/getDistinctQuestions.d.ts +2 -2
  97. package/lib/exercises/utils/getDistinctQuestions.js +15 -15
  98. package/lib/geometry/point.js +27 -27
  99. package/lib/geometry/vector.js +31 -31
  100. package/lib/index.d.ts +3 -2
  101. package/lib/index.d.ts.map +1 -1
  102. package/lib/index.js +39 -6
  103. package/lib/math/geometry/point.d.ts +12 -12
  104. package/lib/math/geometry/point.js +27 -27
  105. package/lib/math/geometry/vector.d.ts +15 -15
  106. package/lib/math/geometry/vector.js +31 -31
  107. package/lib/math/numbers/decimals/decimal.d.ts +24 -24
  108. package/lib/math/numbers/decimals/decimal.js +140 -140
  109. package/lib/math/numbers/epsilon.d.ts +1 -1
  110. package/lib/math/numbers/epsilon.js +10 -10
  111. package/lib/math/numbers/integer/integer.d.ts +14 -14
  112. package/lib/math/numbers/integer/integer.js +68 -68
  113. package/lib/math/numbers/integer/power.d.ts +13 -13
  114. package/lib/math/numbers/integer/power.js +52 -52
  115. package/lib/math/numbers/nombre.d.ts +13 -13
  116. package/lib/math/numbers/nombre.js +10 -10
  117. package/lib/math/numbers/rationals/rational.d.ts +25 -25
  118. package/lib/math/numbers/rationals/rational.js +113 -113
  119. package/lib/math/numbers/reals/real.d.ts +9 -9
  120. package/lib/math/numbers/reals/real.js +16 -16
  121. package/lib/math/numbers/reals/squareRoot.d.ts +18 -18
  122. package/lib/math/numbers/reals/squareRoot.js +63 -63
  123. package/lib/math/polynomials/affine.d.ts +15 -15
  124. package/lib/math/polynomials/affine.js +42 -42
  125. package/lib/math/polynomials/polynomial.d.ts +25 -24
  126. package/lib/math/polynomials/polynomial.d.ts.map +1 -1
  127. package/lib/math/polynomials/polynomial.js +129 -125
  128. package/lib/math/sequences/arithmeticSequence.js +1 -1
  129. package/lib/math/sequences/geometricSequence.d.ts +3 -3
  130. package/lib/math/sequences/geometricSequence.js +8 -8
  131. package/lib/math/sequences/sequence.d.ts +22 -22
  132. package/lib/math/sequences/sequence.js +21 -21
  133. package/lib/math/sets/discreteSet.d.ts +10 -10
  134. package/lib/math/sets/discreteSet.js +28 -28
  135. package/lib/math/sets/emptySet.js +6 -6
  136. package/lib/math/sets/intervals/intervals.d.ts +26 -26
  137. package/lib/math/sets/intervals/intervals.js +104 -104
  138. package/lib/math/sets/mathSet.d.ts +7 -7
  139. package/lib/math/sets/mathSet.js +10 -10
  140. package/lib/math/sets/mathSetInterface.d.ts +5 -5
  141. package/lib/math/sets/mathSetInterface.js +2 -2
  142. package/lib/math/trigonometry/remarkableValue.d.ts +10 -10
  143. package/lib/math/trigonometry/remarkableValue.js +29 -29
  144. package/lib/math/trigonometry/remarkableValues.d.ts +2 -2
  145. package/lib/math/trigonometry/remarkableValues.js +51 -51
  146. package/lib/math/utils/arithmetic/coprimesOf.d.ts +1 -1
  147. package/lib/math/utils/arithmetic/coprimesOf.js +13 -13
  148. package/lib/math/utils/arithmetic/dividersOf.d.ts +1 -1
  149. package/lib/math/utils/arithmetic/dividersOf.js +12 -12
  150. package/lib/math/utils/arithmetic/gcd.d.ts +1 -1
  151. package/lib/math/utils/arithmetic/gcd.js +7 -7
  152. package/lib/math/utils/arithmetic/isSquare.d.ts +1 -1
  153. package/lib/math/utils/arithmetic/isSquare.js +7 -7
  154. package/lib/math/utils/arithmetic/lcd.d.ts +1 -1
  155. package/lib/math/utils/arithmetic/lcd.js +12 -12
  156. package/lib/math/utils/arithmetic/nonCoprimesOf.d.ts +1 -1
  157. package/lib/math/utils/arithmetic/nonCoprimesOf.js +13 -13
  158. package/lib/math/utils/arithmetic/nonDividersOf.d.ts +1 -1
  159. package/lib/math/utils/arithmetic/nonDividersOf.js +14 -14
  160. package/lib/math/utils/arithmetic/primeFactors.d.ts +5 -5
  161. package/lib/math/utils/arithmetic/primeFactors.js +22 -22
  162. package/lib/math/utils/decimals/decimalPartLengthOf.d.ts +1 -1
  163. package/lib/math/utils/decimals/decimalPartLengthOf.js +14 -14
  164. package/lib/math/utils/random/randTupleInt.d.ts +13 -13
  165. package/lib/math/utils/random/randTupleInt.js +30 -30
  166. package/lib/math/utils/random/randint.d.ts +4 -4
  167. package/lib/math/utils/random/randint.js +18 -18
  168. package/lib/math/utils/round.d.ts +1 -1
  169. package/lib/math/utils/round.js +8 -8
  170. package/lib/mathutils/arithmetic/coprimesOf.js +13 -13
  171. package/lib/mathutils/arithmetic/dividersOf.js +12 -12
  172. package/lib/mathutils/arithmetic/gcd.js +7 -7
  173. package/lib/mathutils/arithmetic/isSquare.js +7 -7
  174. package/lib/mathutils/arithmetic/lcd.js +12 -12
  175. package/lib/mathutils/arithmetic/nonCoprimesOf.js +13 -13
  176. package/lib/mathutils/arithmetic/nonDividersOf.js +14 -14
  177. package/lib/mathutils/arithmetic/primeFactors.js +22 -22
  178. package/lib/mathutils/decimals/decimalPartLengthOf.js +14 -14
  179. package/lib/mathutils/random/randTupleInt.js +30 -30
  180. package/lib/mathutils/random/randint.js +18 -18
  181. package/lib/mathutils/round.js +8 -8
  182. package/lib/numbers/decimals/decimal.js +140 -140
  183. package/lib/numbers/epsilon.js +10 -10
  184. package/lib/numbers/integer/integer.js +68 -68
  185. package/lib/numbers/integer/power.js +52 -52
  186. package/lib/numbers/nombre.js +10 -10
  187. package/lib/numbers/rationals/rational.js +113 -113
  188. package/lib/numbers/reals/real.js +16 -16
  189. package/lib/numbers/reals/squareRoot.js +63 -63
  190. package/lib/polynomials/affine.js +42 -42
  191. package/lib/polynomials/polynomial.js +125 -125
  192. package/lib/server.d.ts +2 -0
  193. package/lib/server.d.ts.map +1 -0
  194. package/lib/server.js +33 -0
  195. package/lib/sets/discreteSet.js +28 -28
  196. package/lib/sets/emptySet.js +6 -6
  197. package/lib/sets/intervals/intervals.js +108 -104
  198. package/lib/sets/intervals/union.js +1 -1
  199. package/lib/sets/mathSet.js +10 -10
  200. package/lib/sets/mathSetInterface.js +2 -2
  201. package/lib/tree/nodes/functions/cosNode.d.ts +9 -9
  202. package/lib/tree/nodes/functions/cosNode.js +21 -21
  203. package/lib/tree/nodes/functions/functionNode.d.ts +14 -14
  204. package/lib/tree/nodes/functions/functionNode.js +20 -20
  205. package/lib/tree/nodes/functions/oppositeNode.d.ts +7 -7
  206. package/lib/tree/nodes/functions/oppositeNode.js +26 -26
  207. package/lib/tree/nodes/functions/sinNode.js +1 -1
  208. package/lib/tree/nodes/functions/sqrtNode.d.ts +8 -8
  209. package/lib/tree/nodes/functions/sqrtNode.js +18 -18
  210. package/lib/tree/nodes/node.d.ts +12 -12
  211. package/lib/tree/nodes/node.js +11 -11
  212. package/lib/tree/nodes/numbers/constantNode.d.ts +9 -9
  213. package/lib/tree/nodes/numbers/constantNode.js +18 -18
  214. package/lib/tree/nodes/numbers/numberNode.d.ts +10 -10
  215. package/lib/tree/nodes/numbers/numberNode.js +19 -19
  216. package/lib/tree/nodes/numbers/piNode.d.ts +2 -2
  217. package/lib/tree/nodes/numbers/piNode.js +5 -5
  218. package/lib/tree/nodes/operators/addNode.d.ts +7 -7
  219. package/lib/tree/nodes/operators/addNode.js +19 -19
  220. package/lib/tree/nodes/operators/divideNode.d.ts +11 -11
  221. package/lib/tree/nodes/operators/divideNode.js +34 -34
  222. package/lib/tree/nodes/operators/equalNode.d.ts +7 -7
  223. package/lib/tree/nodes/operators/equalNode.js +16 -16
  224. package/lib/tree/nodes/operators/fractionNode.d.ts +11 -11
  225. package/lib/tree/nodes/operators/fractionNode.js +20 -20
  226. package/lib/tree/nodes/operators/multiplyNode.d.ts +7 -7
  227. package/lib/tree/nodes/operators/multiplyNode.js +43 -43
  228. package/lib/tree/nodes/operators/operatorNode.d.ts +21 -21
  229. package/lib/tree/nodes/operators/operatorNode.js +35 -35
  230. package/lib/tree/nodes/operators/powerNode.d.ts +7 -7
  231. package/lib/tree/nodes/operators/powerNode.js +33 -33
  232. package/lib/tree/nodes/operators/substractNode.d.ts +7 -7
  233. package/lib/tree/nodes/operators/substractNode.js +24 -24
  234. package/lib/tree/nodes/variables/variableNode.d.ts +8 -8
  235. package/lib/tree/nodes/variables/variableNode.js +19 -19
  236. package/lib/tree/parsers/derivateParser.js +62 -62
  237. package/lib/tree/parsers/latexParser.js +110 -110
  238. package/lib/tree/parsers/simplify.d.ts +2 -2
  239. package/lib/tree/parsers/simplify.js +52 -52
  240. package/lib/utils/arrayEqual.d.ts +1 -1
  241. package/lib/utils/arrayEqual.js +13 -13
  242. package/lib/utils/coin.js +7 -7
  243. package/lib/utils/coinFlip.d.ts +1 -1
  244. package/lib/utils/coinFlip.js +7 -7
  245. package/lib/utils/random.d.ts +1 -1
  246. package/lib/utils/random.js +7 -7
  247. package/lib/utils/shuffle.d.ts +1 -1
  248. package/lib/utils/shuffle.js +15 -15
  249. package/package.json +50 -45
  250. package/lib/exercises/calculLitteral/factorisation/factoIdRmq.d.ts +0 -7
  251. package/lib/exercises/calculLitteral/factorisation/factoIdRmq.d.ts.map +0 -1
  252. package/lib/exercises/calculLitteral/factorisation/factoIdRmq.js +0 -38
  253. package/lib/trigonometry/remarkableValue.js +0 -29
  254. package/lib/trigonometry/remarkableValues.js +0 -51
@@ -1,31 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vector = exports.VectorConstructor = void 0;
4
- const addNode_1 = require("../../tree/nodes/operators/addNode");
5
- const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
6
- const substractNode_1 = require("../../tree/nodes/operators/substractNode");
7
- const simplify_1 = require("../../tree/parsers/simplify");
8
- class VectorConstructor {
9
- static fromPoints(origin, end) {
10
- return new Vector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x), new substractNode_1.SubstractNode(end.y, origin.y));
11
- }
12
- }
13
- exports.VectorConstructor = VectorConstructor;
14
- class Vector {
15
- constructor(name, x, y) {
16
- this.name = name;
17
- this.tex = `\\overrightarrow{${name}}`;
18
- this.x = x;
19
- this.y = y;
20
- }
21
- toTex() {
22
- return `\\overrightarrow{${this.name}}`;
23
- }
24
- toTexWithCoords() {
25
- return `\\overrightarrow{${this.name}}\\begin{pmatrix}${this.x.toTex()} \\\\ ${this.y.toTex()} \\end{pmatrix}`;
26
- }
27
- scalarProduct(v) {
28
- return (0, simplify_1.simplifyNode)(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.x, v.x), new multiplyNode_1.MultiplyNode(this.y, v.y)));
29
- }
30
- }
31
- exports.Vector = Vector;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Vector = exports.VectorConstructor = void 0;
4
+ const addNode_1 = require("../../tree/nodes/operators/addNode");
5
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
6
+ const substractNode_1 = require("../../tree/nodes/operators/substractNode");
7
+ const simplify_1 = require("../../tree/parsers/simplify");
8
+ class VectorConstructor {
9
+ static fromPoints(origin, end) {
10
+ return new Vector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x), new substractNode_1.SubstractNode(end.y, origin.y));
11
+ }
12
+ }
13
+ exports.VectorConstructor = VectorConstructor;
14
+ class Vector {
15
+ constructor(name, x, y) {
16
+ this.name = name;
17
+ this.tex = `\\overrightarrow{${name}}`;
18
+ this.x = x;
19
+ this.y = y;
20
+ }
21
+ toTex() {
22
+ return `\\overrightarrow{${this.name}}`;
23
+ }
24
+ toTexWithCoords() {
25
+ return `\\overrightarrow{${this.name}}\\begin{pmatrix}${this.x.toTex()} \\\\ ${this.y.toTex()} \\end{pmatrix}`;
26
+ }
27
+ scalarProduct(v) {
28
+ return (0, simplify_1.simplifyNode)(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.x, v.x), new multiplyNode_1.MultiplyNode(this.y, v.y)));
29
+ }
30
+ }
31
+ exports.Vector = Vector;
@@ -1,25 +1,25 @@
1
- import { Node } from '../../../tree/nodes/node';
2
- import { Nombre, NumberType } from '../nombre';
3
- export declare abstract class DecimalConstructor {
4
- static randomFracPart(precision: number): string;
5
- static random(min: number, max: number, precision: number): Decimal;
6
- static fromParts(intPart: string, decimalPart: string): Decimal;
7
- }
8
- export declare class Decimal implements Nombre {
9
- value: number;
10
- tex: string;
11
- type: NumberType;
12
- precision: number;
13
- intPart: number;
14
- decimalPart: string;
15
- constructor(value: number);
16
- /**
17
- *
18
- * @param precision 0 = unité, 1 = dixieme, ... , -1 : dizaine
19
- * @returns
20
- */
21
- round(precision: number): Nombre;
22
- multiplyByPowerOfTen(power: number): Decimal;
23
- toTree(): Node;
24
- }
1
+ import { Node } from '../../../tree/nodes/node';
2
+ import { Nombre, NumberType } from '../nombre';
3
+ export declare abstract class DecimalConstructor {
4
+ static randomFracPart(precision: number): string;
5
+ static random(min: number, max: number, precision: number): Decimal;
6
+ static fromParts(intPart: string, decimalPart: string): Decimal;
7
+ }
8
+ export declare class Decimal implements Nombre {
9
+ value: number;
10
+ tex: string;
11
+ type: NumberType;
12
+ precision: number;
13
+ intPart: number;
14
+ decimalPart: string;
15
+ constructor(value: number);
16
+ /**
17
+ *
18
+ * @param precision 0 = unité, 1 = dixieme, ... , -1 : dizaine
19
+ * @returns
20
+ */
21
+ round(precision: number): Nombre;
22
+ multiplyByPowerOfTen(power: number): Decimal;
23
+ toTree(): Node;
24
+ }
25
25
  //# sourceMappingURL=decimal.d.ts.map
@@ -1,140 +1,140 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Decimal = exports.DecimalConstructor = void 0;
4
- const randint_1 = require("../../../math/utils/random/randint");
5
- const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
6
- const integer_1 = require("../integer/integer");
7
- const nombre_1 = require("../nombre");
8
- class DecimalConstructor {
9
- static randomFracPart(precision) {
10
- let decimals = '';
11
- for (let i = 0; i < precision; i++) {
12
- decimals += (0, randint_1.randint)(i === precision - 1 ? 1 : 0, 10);
13
- }
14
- return decimals;
15
- }
16
- static random(min, max, precision) {
17
- const int = (0, randint_1.randint)(min, max) + '';
18
- const decimals = DecimalConstructor.randomFracPart(precision);
19
- return DecimalConstructor.fromParts(int, decimals);
20
- }
21
- static fromParts(intPart, decimalPart) {
22
- return new Decimal(Number('' + intPart + '.' + decimalPart));
23
- }
24
- }
25
- exports.DecimalConstructor = DecimalConstructor;
26
- class Decimal {
27
- constructor(value) {
28
- this.type = nombre_1.NumberType.Decimal;
29
- this.value = value;
30
- this.tex = value + '';
31
- let [intPartString, decimalPartString] = (value + '').split('.');
32
- this.intPart = Number(intPartString);
33
- this.decimalPart = decimalPartString || '';
34
- this.precision = this.decimalPart.length;
35
- }
36
- /**
37
- *
38
- * @param precision 0 = unité, 1 = dixieme, ... , -1 : dizaine
39
- * @returns
40
- */
41
- round(precision) {
42
- const intPartString = this.intPart + '';
43
- if (precision < 0) {
44
- if (precision < -intPartString.length)
45
- throw Error("can't round to higher precision");
46
- return new integer_1.Integer(this.intPart).round(-precision);
47
- }
48
- if (precision > this.precision)
49
- throw Error("can't round to higher precision");
50
- if (precision === this.precision)
51
- return this;
52
- let newFracPart = '', newIntPart = '';
53
- const shouldRoundUp = Number(this.decimalPart[precision]) > 4;
54
- if (shouldRoundUp) {
55
- let retenue = true;
56
- let i = precision - 1;
57
- while (retenue) {
58
- if (i > -1) {
59
- const nb = (Number(this.decimalPart[i]) + 1) % 10;
60
- if (nb || newFracPart) {
61
- newFracPart = nb.toString() + newFracPart;
62
- }
63
- if (nb !== 0) {
64
- retenue = false;
65
- for (let j = i - 1; j > -1; j--) {
66
- newFracPart = this.decimalPart[j] + newFracPart;
67
- }
68
- newIntPart = intPartString;
69
- }
70
- else
71
- i--;
72
- }
73
- else {
74
- const nb = (Number(intPartString[i + intPartString.length]) + 1) % 10;
75
- newIntPart = nb + '' + newIntPart;
76
- if (nb !== 0) {
77
- retenue = false;
78
- for (let j = i + intPartString.length - 1; j > -1; j--) {
79
- newIntPart = intPartString[j] + newIntPart;
80
- }
81
- }
82
- else
83
- i--;
84
- }
85
- }
86
- }
87
- else {
88
- let retenue = true;
89
- let i = precision - 1;
90
- while (retenue) {
91
- if (i > -1) {
92
- const nb = Number(this.decimalPart[i]);
93
- if (nb || newFracPart) {
94
- newFracPart = nb.toString() + newFracPart;
95
- }
96
- if (nb !== 0) {
97
- retenue = false;
98
- for (let j = i - 1; j > -1; j--) {
99
- newFracPart = this.decimalPart[j] + newFracPart;
100
- }
101
- newIntPart = intPartString;
102
- }
103
- else
104
- i--;
105
- }
106
- else {
107
- newIntPart = intPartString;
108
- retenue = false;
109
- }
110
- }
111
- }
112
- return DecimalConstructor.fromParts(newIntPart, newFracPart);
113
- }
114
- multiplyByPowerOfTen(power) {
115
- let newIntPart = '', newFracPart = '';
116
- if (power > -1) {
117
- newIntPart = this.intPart + '';
118
- for (let i = 0; i < power; i++) {
119
- newIntPart += i > this.decimalPart.length - 1 ? '0' : this.decimalPart[i];
120
- }
121
- newFracPart = this.decimalPart.slice(power);
122
- }
123
- else {
124
- const intPartString = this.intPart + '';
125
- newFracPart = this.decimalPart;
126
- for (let i = intPartString.length - 1; i > intPartString.length - 1 + power; i--) {
127
- newFracPart = (i < 0 ? '0' : intPartString[i]) + newFracPart;
128
- }
129
- if (power + intPartString.length < 1)
130
- newIntPart = '0';
131
- else
132
- newIntPart = intPartString.slice(0, power + intPartString.length);
133
- }
134
- return DecimalConstructor.fromParts(newIntPart, newFracPart);
135
- }
136
- toTree() {
137
- return new numberNode_1.NumberNode(this.value);
138
- }
139
- }
140
- exports.Decimal = Decimal;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Decimal = exports.DecimalConstructor = void 0;
4
+ const randint_1 = require("../../../math/utils/random/randint");
5
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
6
+ const integer_1 = require("../integer/integer");
7
+ const nombre_1 = require("../nombre");
8
+ class DecimalConstructor {
9
+ static randomFracPart(precision) {
10
+ let decimals = '';
11
+ for (let i = 0; i < precision; i++) {
12
+ decimals += (0, randint_1.randint)(i === precision - 1 ? 1 : 0, 10);
13
+ }
14
+ return decimals;
15
+ }
16
+ static random(min, max, precision) {
17
+ const int = (0, randint_1.randint)(min, max) + '';
18
+ const decimals = DecimalConstructor.randomFracPart(precision);
19
+ return DecimalConstructor.fromParts(int, decimals);
20
+ }
21
+ static fromParts(intPart, decimalPart) {
22
+ return new Decimal(Number('' + intPart + '.' + decimalPart));
23
+ }
24
+ }
25
+ exports.DecimalConstructor = DecimalConstructor;
26
+ class Decimal {
27
+ constructor(value) {
28
+ this.type = nombre_1.NumberType.Decimal;
29
+ this.value = value;
30
+ this.tex = value + '';
31
+ let [intPartString, decimalPartString] = (value + '').split('.');
32
+ this.intPart = Number(intPartString);
33
+ this.decimalPart = decimalPartString || '';
34
+ this.precision = this.decimalPart.length;
35
+ }
36
+ /**
37
+ *
38
+ * @param precision 0 = unité, 1 = dixieme, ... , -1 : dizaine
39
+ * @returns
40
+ */
41
+ round(precision) {
42
+ const intPartString = this.intPart + '';
43
+ if (precision < 0) {
44
+ if (precision < -intPartString.length)
45
+ throw Error("can't round to higher precision");
46
+ return new integer_1.Integer(this.intPart).round(-precision);
47
+ }
48
+ if (precision > this.precision)
49
+ throw Error("can't round to higher precision");
50
+ if (precision === this.precision)
51
+ return this;
52
+ let newFracPart = '', newIntPart = '';
53
+ const shouldRoundUp = Number(this.decimalPart[precision]) > 4;
54
+ if (shouldRoundUp) {
55
+ let retenue = true;
56
+ let i = precision - 1;
57
+ while (retenue) {
58
+ if (i > -1) {
59
+ const nb = (Number(this.decimalPart[i]) + 1) % 10;
60
+ if (nb || newFracPart) {
61
+ newFracPart = nb.toString() + newFracPart;
62
+ }
63
+ if (nb !== 0) {
64
+ retenue = false;
65
+ for (let j = i - 1; j > -1; j--) {
66
+ newFracPart = this.decimalPart[j] + newFracPart;
67
+ }
68
+ newIntPart = intPartString;
69
+ }
70
+ else
71
+ i--;
72
+ }
73
+ else {
74
+ const nb = (Number(intPartString[i + intPartString.length]) + 1) % 10;
75
+ newIntPart = nb + '' + newIntPart;
76
+ if (nb !== 0) {
77
+ retenue = false;
78
+ for (let j = i + intPartString.length - 1; j > -1; j--) {
79
+ newIntPart = intPartString[j] + newIntPart;
80
+ }
81
+ }
82
+ else
83
+ i--;
84
+ }
85
+ }
86
+ }
87
+ else {
88
+ let retenue = true;
89
+ let i = precision - 1;
90
+ while (retenue) {
91
+ if (i > -1) {
92
+ const nb = Number(this.decimalPart[i]);
93
+ if (nb || newFracPart) {
94
+ newFracPart = nb.toString() + newFracPart;
95
+ }
96
+ if (nb !== 0) {
97
+ retenue = false;
98
+ for (let j = i - 1; j > -1; j--) {
99
+ newFracPart = this.decimalPart[j] + newFracPart;
100
+ }
101
+ newIntPart = intPartString;
102
+ }
103
+ else
104
+ i--;
105
+ }
106
+ else {
107
+ newIntPart = intPartString;
108
+ retenue = false;
109
+ }
110
+ }
111
+ }
112
+ return DecimalConstructor.fromParts(newIntPart, newFracPart);
113
+ }
114
+ multiplyByPowerOfTen(power) {
115
+ let newIntPart = '', newFracPart = '';
116
+ if (power > -1) {
117
+ newIntPart = this.intPart + '';
118
+ for (let i = 0; i < power; i++) {
119
+ newIntPart += i > this.decimalPart.length - 1 ? '0' : this.decimalPart[i];
120
+ }
121
+ newFracPart = this.decimalPart.slice(power);
122
+ }
123
+ else {
124
+ const intPartString = this.intPart + '';
125
+ newFracPart = this.decimalPart;
126
+ for (let i = intPartString.length - 1; i > intPartString.length - 1 + power; i--) {
127
+ newFracPart = (i < 0 ? '0' : intPartString[i]) + newFracPart;
128
+ }
129
+ if (power + intPartString.length < 1)
130
+ newIntPart = '0';
131
+ else
132
+ newIntPart = intPartString.slice(0, power + intPartString.length);
133
+ }
134
+ return DecimalConstructor.fromParts(newIntPart, newFracPart);
135
+ }
136
+ toTree() {
137
+ return new numberNode_1.NumberNode(this.value);
138
+ }
139
+ }
140
+ exports.Decimal = Decimal;
@@ -1,2 +1,2 @@
1
- export declare const EPSILON: number;
1
+ export declare const EPSILON: number;
2
2
  //# sourceMappingURL=epsilon.d.ts.map
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EPSILON = void 0;
4
- function getEpsilon() {
5
- var e = 1.0;
6
- while (1.0 + 0.5 * e !== 1.0)
7
- e *= 0.5;
8
- return e;
9
- }
10
- exports.EPSILON = getEpsilon();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EPSILON = void 0;
4
+ function getEpsilon() {
5
+ var e = 1.0;
6
+ while (1.0 + 0.5 * e !== 1.0)
7
+ e *= 0.5;
8
+ return e;
9
+ }
10
+ exports.EPSILON = getEpsilon();
@@ -1,15 +1,15 @@
1
- import { Node } from '../../../tree/nodes/node';
2
- import { Nombre, NumberType } from '../nombre';
3
- export declare abstract class IntegerConstructor {
4
- static random(nbOfDigits: number): number;
5
- }
6
- export declare class Integer implements Nombre {
7
- value: number;
8
- tex: string;
9
- type: NumberType;
10
- constructor(value: number, tex?: string);
11
- toTree(): Node;
12
- round(precision: number): Integer;
13
- divide(nb: Nombre): Nombre;
14
- }
1
+ import { Node } from '../../../tree/nodes/node';
2
+ import { Nombre, NumberType } from '../nombre';
3
+ export declare abstract class IntegerConstructor {
4
+ static random(nbOfDigits: number): number;
5
+ }
6
+ export declare class Integer implements Nombre {
7
+ value: number;
8
+ tex: string;
9
+ type: NumberType;
10
+ constructor(value: number, tex?: string);
11
+ toTree(): Node;
12
+ round(precision: number): Integer;
13
+ divide(nb: Nombre): Nombre;
14
+ }
15
15
  //# sourceMappingURL=integer.d.ts.map
@@ -1,68 +1,68 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Integer = exports.IntegerConstructor = void 0;
4
- const randint_1 = require("../../../math/utils/random/randint");
5
- const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
6
- const nombre_1 = require("../nombre");
7
- const rational_1 = require("../rationals/rational");
8
- class IntegerConstructor {
9
- static random(nbOfDigits) {
10
- return (0, randint_1.randint)(0, 10 ** nbOfDigits);
11
- }
12
- }
13
- exports.IntegerConstructor = IntegerConstructor;
14
- class Integer {
15
- constructor(value, tex) {
16
- this.value = value;
17
- this.tex = tex || value + '';
18
- this.type = nombre_1.NumberType.Integer;
19
- }
20
- toTree() {
21
- return new numberNode_1.NumberNode(this.value, this.tex);
22
- }
23
- round(precision) {
24
- const intString = this.value + '';
25
- if (precision >= intString.length || precision < 1)
26
- throw Error("can't round to higher precision");
27
- let newInt = '';
28
- const shouldRoundUp = Number(intString[intString.length - precision]) > 4;
29
- if (shouldRoundUp) {
30
- for (let i = 0; i < precision; i++) {
31
- newInt += '0';
32
- }
33
- let retenue = true;
34
- let i = intString.length - precision - 1;
35
- while (retenue) {
36
- const nb = (Number(intString[i]) + 1) % 10;
37
- newInt = '' + nb + newInt;
38
- if (nb === 0) {
39
- i--;
40
- }
41
- else {
42
- retenue = false;
43
- for (let j = i - 1; j > -1; j--) {
44
- newInt = intString[j] + newInt;
45
- }
46
- }
47
- }
48
- }
49
- else {
50
- for (let i = 0; i < intString.length; i++) {
51
- newInt += i < intString.length - precision ? intString[i] : '0';
52
- }
53
- }
54
- return new Integer(Number(newInt));
55
- }
56
- divide(nb) {
57
- switch (nb.type) {
58
- case nombre_1.NumberType.Integer:
59
- return new rational_1.Rational(this.value, nb.value).simplify();
60
- case nombre_1.NumberType.Rational:
61
- const rational = nb;
62
- return new rational_1.Rational(this.value * rational.denum, rational.num).simplify();
63
- default:
64
- throw Error('not implemented');
65
- }
66
- }
67
- }
68
- exports.Integer = Integer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Integer = exports.IntegerConstructor = void 0;
4
+ const randint_1 = require("../../../math/utils/random/randint");
5
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
6
+ const nombre_1 = require("../nombre");
7
+ const rational_1 = require("../rationals/rational");
8
+ class IntegerConstructor {
9
+ static random(nbOfDigits) {
10
+ return (0, randint_1.randint)(0, 10 ** nbOfDigits);
11
+ }
12
+ }
13
+ exports.IntegerConstructor = IntegerConstructor;
14
+ class Integer {
15
+ constructor(value, tex) {
16
+ this.value = value;
17
+ this.tex = tex || value + '';
18
+ this.type = nombre_1.NumberType.Integer;
19
+ }
20
+ toTree() {
21
+ return new numberNode_1.NumberNode(this.value, this.tex);
22
+ }
23
+ round(precision) {
24
+ const intString = this.value + '';
25
+ if (precision >= intString.length || precision < 1)
26
+ throw Error("can't round to higher precision");
27
+ let newInt = '';
28
+ const shouldRoundUp = Number(intString[intString.length - precision]) > 4;
29
+ if (shouldRoundUp) {
30
+ for (let i = 0; i < precision; i++) {
31
+ newInt += '0';
32
+ }
33
+ let retenue = true;
34
+ let i = intString.length - precision - 1;
35
+ while (retenue) {
36
+ const nb = (Number(intString[i]) + 1) % 10;
37
+ newInt = '' + nb + newInt;
38
+ if (nb === 0) {
39
+ i--;
40
+ }
41
+ else {
42
+ retenue = false;
43
+ for (let j = i - 1; j > -1; j--) {
44
+ newInt = intString[j] + newInt;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ else {
50
+ for (let i = 0; i < intString.length; i++) {
51
+ newInt += i < intString.length - precision ? intString[i] : '0';
52
+ }
53
+ }
54
+ return new Integer(Number(newInt));
55
+ }
56
+ divide(nb) {
57
+ switch (nb.type) {
58
+ case nombre_1.NumberType.Integer:
59
+ return new rational_1.Rational(this.value, nb.value).simplify();
60
+ case nombre_1.NumberType.Rational:
61
+ const rational = nb;
62
+ return new rational_1.Rational(this.value * rational.denum, rational.num).simplify();
63
+ default:
64
+ throw Error('not implemented');
65
+ }
66
+ }
67
+ }
68
+ exports.Integer = Integer;
@@ -1,14 +1,14 @@
1
- import { Node } from '../../../tree/nodes/node';
2
- import { Nombre, NumberType } from '../nombre';
3
- export declare class Power implements Nombre {
4
- value: number;
5
- tex: string;
6
- type: NumberType;
7
- operand: number;
8
- power: number;
9
- constructor(a: number, b: number);
10
- simplify(): Node;
11
- toDecimalWriting(): Nombre;
12
- toTree(): Node;
13
- }
1
+ import { Node } from '../../../tree/nodes/node';
2
+ import { Nombre, NumberType } from '../nombre';
3
+ export declare class Power implements Nombre {
4
+ value: number;
5
+ tex: string;
6
+ type: NumberType;
7
+ operand: number;
8
+ power: number;
9
+ constructor(a: number, b: number);
10
+ simplify(): Node;
11
+ toDecimalWriting(): Nombre;
12
+ toTree(): Node;
13
+ }
14
14
  //# sourceMappingURL=power.d.ts.map