Logo

Programming-Idioms

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

Idiom #337 Convert string to integer, explicit base

Extract the integer value i from its string representation s, in radix b

i := StrToInt64Base(s, b);
#include <stdlib.h>
int i = strtol(s, NULL, b);
import "strconv"
i, err := strconv.ParseInt(s, b, 0)
Integer i = Integer.valueOf(s, b);
i = int(s, b)
i = s.to_i(b)

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