Java Integer to intToAlgebraicLoc(int loc)

Here you can find the source of intToAlgebraicLoc(int loc)

Description

Converts an integer location in [0, 64) to a string in "algebraic notation" (ie.

License

Open Source License

Parameter

Parameter Description
loc an int in [0, 64) representing a location

Return

the "algebraic notation" of the location

Declaration

public static String intToAlgebraicLoc(int loc) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  w w w  .j  a  va2s .c o m
     * Converts an integer location in [0, 64) to a string in
     * "algebraic notation" (ie. of the form 'a7', 'c5).
     * 
     * @param loc
     *            an int in [0, 64) representing a location
     * @return the "algebraic notation" of the location
     */
    public static String intToAlgebraicLoc(int loc) {
        if (loc == -1)
            return "-";
        int out = loc % 8;
        int up = loc / 8;
        char outc = (char) (out + 'a');
        char upc = (char) (up + '1');
        return outc + "" + upc;
    }
}

Related

  1. int2sortableStr(int val)
  2. int2TwoChars(int i)
  3. intTo2LengthBytes(int i)
  4. intTo2UnsignedBytes(int val)
  5. intTo8HexString(int i)
  6. intToAlpha(Integer no)
  7. intToASN1(byte[] d, int idx, int val)
  8. intToBase32(int n)
  9. intToBasicType(int i, Class clazz)