exponential-number 1.2.0 → 1.2.2
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/package.json +2 -1
- package/src/class/exponent-number.class.ts +3 -3
- package/test/test.ts +18 -18
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exponential-number",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Small package with class to work with big numbers. This class allows to work with 1e...(1.8e308)...e1e100. Allowed methods",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
|
+
"repository": "https://github.com/AlexSmykov/exponential-numbers",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"build": "tsc -w",
|
|
11
12
|
"test": "jest --config=jest.config.js test.ts"
|
|
@@ -212,7 +212,7 @@ export class ExponentNumber {
|
|
|
212
212
|
return new ExponentNumber(this.exponentFactor - 1, this.value);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
isGreaterThanValue(otherNumber: ExponentNumber): boolean {
|
|
216
216
|
return (
|
|
217
217
|
this.exponentFactor > otherNumber.exponentFactor ||
|
|
218
218
|
(this.exponentFactor === otherNumber.exponentFactor && this.value > otherNumber.value)
|
|
@@ -223,7 +223,7 @@ export class ExponentNumber {
|
|
|
223
223
|
return otherNumber.exponentFactor === this.exponentFactor && otherNumber.value === this.value;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
return this.
|
|
226
|
+
isGreaterThanOrEqualValue(otherNumber: ExponentNumber): boolean {
|
|
227
|
+
return this.isGreaterThanValue(otherNumber) || this.isEqual(otherNumber);
|
|
228
228
|
}
|
|
229
229
|
}
|
package/test/test.ts
CHANGED
|
@@ -690,55 +690,55 @@ describe('More than test', () => {
|
|
|
690
690
|
test('1', () => {
|
|
691
691
|
const first = new ExponentNumber(0, 1);
|
|
692
692
|
const second = new ExponentNumber(0, 1);
|
|
693
|
-
expect(first.
|
|
693
|
+
expect(first.isGreaterThanValue(second)).toBe(false);
|
|
694
694
|
});
|
|
695
695
|
|
|
696
696
|
test('2', () => {
|
|
697
697
|
const first = new ExponentNumber(0, 1);
|
|
698
698
|
const second = new ExponentNumber(0, 2);
|
|
699
|
-
expect(first.
|
|
699
|
+
expect(first.isGreaterThanValue(second)).toBe(false);
|
|
700
700
|
});
|
|
701
701
|
|
|
702
702
|
test('3', () => {
|
|
703
703
|
const first = new ExponentNumber(0, 2);
|
|
704
704
|
const second = new ExponentNumber(0, 1);
|
|
705
|
-
expect(first.
|
|
705
|
+
expect(first.isGreaterThanValue(second)).toBe(true);
|
|
706
706
|
});
|
|
707
707
|
|
|
708
708
|
test('4', () => {
|
|
709
709
|
const first = new ExponentNumber(1, 1);
|
|
710
710
|
const second = new ExponentNumber(0, 1);
|
|
711
|
-
expect(first.
|
|
711
|
+
expect(first.isGreaterThanValue(second)).toBe(true);
|
|
712
712
|
});
|
|
713
713
|
|
|
714
714
|
test('5', () => {
|
|
715
715
|
const first = new ExponentNumber(1, 1);
|
|
716
716
|
const second = new ExponentNumber(1, 1);
|
|
717
|
-
expect(first.
|
|
717
|
+
expect(first.isGreaterThanValue(second)).toBe(false);
|
|
718
718
|
});
|
|
719
719
|
|
|
720
720
|
test('6', () => {
|
|
721
721
|
const first = new ExponentNumber(1, 2);
|
|
722
722
|
const second = new ExponentNumber(1, 1);
|
|
723
|
-
expect(first.
|
|
723
|
+
expect(first.isGreaterThanValue(second)).toBe(true);
|
|
724
724
|
});
|
|
725
725
|
|
|
726
726
|
test('7', () => {
|
|
727
727
|
const first = new ExponentNumber(1, 1);
|
|
728
728
|
const second = new ExponentNumber(2, 1);
|
|
729
|
-
expect(first.
|
|
729
|
+
expect(first.isGreaterThanValue(second)).toBe(false);
|
|
730
730
|
});
|
|
731
731
|
|
|
732
732
|
test('8', () => {
|
|
733
733
|
const first = new ExponentNumber(1, 1);
|
|
734
734
|
const second = new ExponentNumber(1, 2);
|
|
735
|
-
expect(first.
|
|
735
|
+
expect(first.isGreaterThanValue(second)).toBe(false);
|
|
736
736
|
});
|
|
737
737
|
|
|
738
738
|
test('9', () => {
|
|
739
739
|
const first = new ExponentNumber(100, 100);
|
|
740
740
|
const second = new ExponentNumber(99, 101);
|
|
741
|
-
expect(first.
|
|
741
|
+
expect(first.isGreaterThanValue(second)).toBe(true);
|
|
742
742
|
});
|
|
743
743
|
});
|
|
744
744
|
|
|
@@ -802,54 +802,54 @@ describe('More than or equal test', () => {
|
|
|
802
802
|
test('1', () => {
|
|
803
803
|
const first = new ExponentNumber(0, 1);
|
|
804
804
|
const second = new ExponentNumber(0, 1);
|
|
805
|
-
expect(first.
|
|
805
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(true);
|
|
806
806
|
});
|
|
807
807
|
|
|
808
808
|
test('2', () => {
|
|
809
809
|
const first = new ExponentNumber(0, 1);
|
|
810
810
|
const second = new ExponentNumber(0, 2);
|
|
811
|
-
expect(first.
|
|
811
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(false);
|
|
812
812
|
});
|
|
813
813
|
|
|
814
814
|
test('3', () => {
|
|
815
815
|
const first = new ExponentNumber(0, 2);
|
|
816
816
|
const second = new ExponentNumber(0, 1);
|
|
817
|
-
expect(first.
|
|
817
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(true);
|
|
818
818
|
});
|
|
819
819
|
|
|
820
820
|
test('4', () => {
|
|
821
821
|
const first = new ExponentNumber(1, 1);
|
|
822
822
|
const second = new ExponentNumber(0, 1);
|
|
823
|
-
expect(first.
|
|
823
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(true);
|
|
824
824
|
});
|
|
825
825
|
|
|
826
826
|
test('5', () => {
|
|
827
827
|
const first = new ExponentNumber(1, 1);
|
|
828
828
|
const second = new ExponentNumber(1, 1);
|
|
829
|
-
expect(first.
|
|
829
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(true);
|
|
830
830
|
});
|
|
831
831
|
|
|
832
832
|
test('6', () => {
|
|
833
833
|
const first = new ExponentNumber(1, 2);
|
|
834
834
|
const second = new ExponentNumber(1, 1);
|
|
835
|
-
expect(first.
|
|
835
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(true);
|
|
836
836
|
});
|
|
837
837
|
|
|
838
838
|
test('7', () => {
|
|
839
839
|
const first = new ExponentNumber(1, 1);
|
|
840
840
|
const second = new ExponentNumber(2, 1);
|
|
841
|
-
expect(first.
|
|
841
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(false);
|
|
842
842
|
});
|
|
843
843
|
|
|
844
844
|
test('8', () => {
|
|
845
845
|
const first = new ExponentNumber(1, 1);
|
|
846
846
|
const second = new ExponentNumber(1, 2);
|
|
847
|
-
expect(first.
|
|
847
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(false);
|
|
848
848
|
});
|
|
849
849
|
|
|
850
850
|
test('9', () => {
|
|
851
851
|
const first = new ExponentNumber(100, 100);
|
|
852
852
|
const second = new ExponentNumber(99, 101);
|
|
853
|
-
expect(first.
|
|
853
|
+
expect(first.isGreaterThanOrEqualValue(second)).toBe(true);
|
|
854
854
|
});
|
|
855
855
|
});
|