diff --git a/lib/std/math/bigint.c3 b/lib/std/math/bigint.c3 index 392850c66..5fb303099 100644 --- a/lib/std/math/bigint.c3 +++ b/lib/std/math/bigint.c3 @@ -92,9 +92,9 @@ fn BigInt*! BigInt.init_string_radix(&self, String value, int radix) case '0'..'9': pos_val -= '0'; case 'A'..'Z': - pos_val -= 'A' + 10; + pos_val -= 'A' - 10; case 'a'..'z': - pos_val -= 'a' + 10; + pos_val -= 'a' - 10; default: return NumberConversion.MALFORMED_INTEGER?; } diff --git a/releasenotes.md b/releasenotes.md index 9388469bc..07e5dada3 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -49,6 +49,7 @@ - Allow function types to have a calling convention. #1938 - Issue with defer copying when triggered by break or continue #1936. - Assert when using optional as init or inc part in a for loop #1942. +- Fix bigint hex parsing #1945. ### Stdlib changes - Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter. diff --git a/test/unit/stdlib/math/bigint.c3 b/test/unit/stdlib/math/bigint.c3 index 0117159db..db99ae935 100644 --- a/test/unit/stdlib/math/bigint.c3 +++ b/test/unit/stdlib/math/bigint.c3 @@ -1,5 +1,11 @@ module std::math::bigint @test; +fn void test_parse16() +{ + BigInt bi @noinit; + assert(bi.init_string_radix("c", 16)!!.equals(bigint::from_int(12))); +} + fn void test_plus() { BigInt a = bigint::from_int(123);