Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error encountered while using the toInt function #131

Open
lanbairua opened this issue Jul 8, 2023 · 1 comment
Open

Error encountered while using the toInt function #131

lanbairua opened this issue Jul 8, 2023 · 1 comment

Comments

@lanbairua
Copy link

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!

@konsumlamm
Copy link
Contributor

You need to specify the specific integer type you want to convert to, e.g. i.toInt[:int] or toInt[int](i).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants