diff --git a/README.md b/README.md index 810da541..ca980280 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,13 @@ Sum: Sum: 9223372039002259454 #### Subtraction ```kotlin -val a = BigInteger.fromLong(1L) -val b = BigInteger.fromInt(2L) +val a = BigInteger.fromLong(Long.MIN_VALUE) +val b = BigInteger.fromLong(Long.MAX_VALUE) val difference = a - b println("Difference: $difference") ----- Output ----- -Difference: 3 +Difference: -18446744073709551615 ``` #### Multiplication diff --git a/bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/integer/BigIntegerReadmeTest.kt b/bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/integer/BigIntegerReadmeTest.kt index 2583e6e6..6f36bc39 100644 --- a/bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/integer/BigIntegerReadmeTest.kt +++ b/bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/integer/BigIntegerReadmeTest.kt @@ -33,18 +33,24 @@ class BigIntegerReadmeTest { fun `Test_readme_addition_sample`() { val a = BigInteger.fromLong(Long.MAX_VALUE) val b = BigInteger.fromInt(Int.MAX_VALUE) - val sum = a + b println("Sum: $sum") + + val expectedResult = BigInteger.parseString("9223372039002259454", 10) + assertTrue { sum == expectedResult } + } @Test fun `Test_readme_subtraction_sample`() { val a = BigInteger.fromLong(Long.MIN_VALUE) - val b = BigInteger.fromLong(Long.MIN_VALUE) + val b = BigInteger.fromLong(Long.MAX_VALUE) val difference = a - b println("Difference: $difference") + + val expectedResult = BigInteger.parseString("-18446744073709551615", 10) + assertTrue { difference == expectedResult } } @Test