Here you can find the source of fromOtherBaseToDecimal(int base, String number)
Parameter | Description |
---|---|
base | the base counting system of the input |
number | the input value to be converted |
private static int fromOtherBaseToDecimal(int base, String number)
//package com.java2s; public class Main { private static final String baseDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /**/*from w ww. ja v a 2 s .co m*/ * Converts a number from another base to the decimal counting system * @param base the base counting system of the input * @param number the input value to be converted * @return the converted decimal value */ private static int fromOtherBaseToDecimal(int base, String number) { int iterator = number.length(); int returnValue = 0; int multiplier = 1; while (iterator > 0) { returnValue = returnValue + (baseDigits.indexOf(number.substring(iterator - 1, iterator)) * multiplier); multiplier = multiplier * base; --iterator; } return returnValue; } }