Java Base Convert fromBase36(String base36Number)

Here you can find the source of fromBase36(String base36Number)

Description

from Base

License

Open Source License

Declaration

public static int fromBase36(String base36Number) 

Method Source Code

//package com.java2s;
/***********************************************************************************
 * AlgoTrader Enterprise Trading Framework
 *
 * Copyright (C) 2015 AlgoTrader GmbH - All rights reserved
 *
 * All information contained herein is, and remains the property of AlgoTrader GmbH.
 * The intellectual and technical concepts contained herein are proprietary to
 * AlgoTrader GmbH. Modification, translation, reverse engineering, decompilation,
 * disassembly or reproduction of this material is strictly forbidden unless prior
 * written permission is obtained from AlgoTrader GmbH
 *
 * Fur detailed terms and conditions consult the file LICENSE.txt or contact
 *
 * AlgoTrader GmbH/*  ww w.  j a  va 2  s  . c o  m*/
 * Aeschstrasse 6
 * 8834 Schindellegi
 ***********************************************************************************/

public class Main {
    private static final String baseDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

    public static int fromBase36(String base36Number) {
        return fromOtherBaseToDecimal(36, base36Number);
    }

    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;
    }
}

Related

  1. fromBase16(String data)
  2. fromBase16toByteArray(String bytes)
  3. fromBase16toIntArray(String bytes)
  4. fromBase26(String number)
  5. fromBase36(String base36)
  6. fromBase58(String input)
  7. fromBase62(String base62Number)