Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Go: convert big.Int to regular integer (int, int32, int64)

$
0
0

I assumed this would be a simple issue with abundant answers on the Internet. But that does not appear to be the case.

I need to convert a Go big.Int into a regular integer (e.g., int, int32, or int64). But there appears to be no straightforward way to do this.

I've tried int(bigVal), int32(bigVal), and int64(bigVal), but they give the error cannot convert bigVal(variable of type big.Int) to type x (where x is either int, int32 or int64).

I'm finding myself frustrated over how Go makes handling big numbers so complicated (in contrast to the relative ease of, say, C#/.NET's System.Numerics.BigInteger). How do I accomplish this, something that should a trivially easy task?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>