Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #345 Convert string to big integer

Create the integer value i initialized from its string representation s (in radix 10)

Use an integer type that can hold huge values. Explain what happens if s cannot be parsed.

i = s.to_i
import "math/big"
i := new(big.Int)
_, ok := i.SetString(s, 10)
import java.math.BigInteger;
BigInteger i = new BigInteger(s, 10);
i = int(s)

New implementation...
< >
programming-idioms.org