File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/integer Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -67,13 +67,13 @@ Sum: Sum: 9223372039002259454
67
67
68
68
#### Subtraction
69
69
``` kotlin
70
- val a = BigInteger .fromLong(1L )
71
- val b = BigInteger .fromInt( 2L )
70
+ val a = BigInteger .fromLong(Long . MIN_VALUE )
71
+ val b = BigInteger .fromLong( Long . MAX_VALUE )
72
72
73
73
val difference = a - b
74
74
println (" Difference: $difference " )
75
75
---- - Output ---- -
76
- Difference : 3
76
+ Difference : - 18446744073709551615
77
77
```
78
78
79
79
#### Multiplication
Original file line number Diff line number Diff line change @@ -33,18 +33,24 @@ class BigIntegerReadmeTest {
33
33
fun `Test_readme_addition_sample` () {
34
34
val a = BigInteger .fromLong(Long .MAX_VALUE )
35
35
val b = BigInteger .fromInt(Int .MAX_VALUE )
36
-
37
36
val sum = a + b
38
37
println (" Sum: $sum " )
38
+
39
+ val expectedResult = BigInteger .parseString(" 9223372039002259454" , 10 )
40
+ assertTrue { sum == expectedResult }
41
+
39
42
}
40
43
41
44
@Test
42
45
fun `Test_readme_subtraction_sample` () {
43
46
val a = BigInteger .fromLong(Long .MIN_VALUE )
44
- val b = BigInteger .fromLong(Long .MIN_VALUE )
47
+ val b = BigInteger .fromLong(Long .MAX_VALUE )
45
48
46
49
val difference = a - b
47
50
println (" Difference: $difference " )
51
+
52
+ val expectedResult = BigInteger .parseString(" -18446744073709551615" , 10 )
53
+ assertTrue { difference == expectedResult }
48
54
}
49
55
50
56
@Test
You can’t perform that action at this time.
0 commit comments