bigints
bigints copied to clipboard
Error encountered while using the `toInt` function
Hello,
I encountered a problem while using the bigints library. When I tried to use the toInt function to convert a value of type BigInt to type int, the following error message appeared:
template/generic instantiation of `toInt` from here
Error: cannot instantiate: 'T'
Here is my code snippet:
# 示例
var charset = "abc"
let length = 2
let startFrom = "ab"
let endAt = "bc"
let startNumber: BigInt = getStartNumber(startFrom, charset, length)
let endNumber: BigInt = getEndNumber(endAt, charset, length)
for i in startNumber..endNumber:
echo fromDecimal(charset, i.toInt, length)
My Nim version is nim-1.6.4 and the bigints library version is bigints-1.1.0.
How can this problem be solved? Thank you!
You need to specify the specific integer type you want to convert to, e.g. i.toInt[:int] or toInt[int](i).