From 389da7588fc64ddc52229289df2e3d05f4e86bdb Mon Sep 17 00:00:00 2001 From: mratsim Date: Tue, 3 Apr 2018 15:12:27 +0200 Subject: [PATCH 1/2] Add broken pow test --- tests/test1.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test1.nim b/tests/test1.nim index 0ba8f3f..96667ff 100644 --- a/tests/test1.nim +++ b/tests/test1.nim @@ -21,6 +21,7 @@ suite "ttmath": a + b == "28497092031222200795837".u256 a + b != "28497092031222200795838".u256 a + b < "28497092031222200795838".u256 + pow(2.u256, 3) == 8.u256 suite "Testing conversion functions: Hex, Bytes, Endianness": let From 974a6eba54e754704ca8fb787d615057f636e035 Mon Sep 17 00:00:00 2001 From: mratsim Date: Tue, 3 Apr 2018 15:15:03 +0200 Subject: [PATCH 2/2] Fix Pow - input should be uint for proper int literal conversion --- src/ttmath.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ttmath.nim b/src/ttmath.nim index 1a5b1e5..9a39fe8 100644 --- a/src/ttmath.nim +++ b/src/ttmath.nim @@ -106,7 +106,7 @@ proc pow*(a: Int, b: int): Int = tmp.inplacePow(initInt[Int](b)) result = tmp -proc pow*(a: UInt, b: int): UInt = +proc pow*(a: UInt, b: uint): UInt = var tmp = a tmp.inplacePow(initUInt[UInt](b)) result = tmp