Sha256: e241dbaa4ef87e1fa8b8ad77b65760fa833eb8ecd4f5ef1e95659deba7ed408a
Contents?: true
Size: 404 Bytes
Versions: 290
Compression:
Stored size: 404 Bytes
Contents
import java.util.Arrays; public class Hexadecimal { private static final String HEXES = "0123456789abcdef"; public static int toDecimal(String input){ boolean isHex = input.matches("^[0-9a-f]+"); if (!isHex) return 0; return Arrays.stream(input.split("")) .map(HEXES::indexOf) .reduce(0, (decimal, hex) -> decimal * 16 + hex); } }
Version data entries
290 entries across 290 versions & 1 rubygems