Java Bits Convert to bit(int row, int col)

Here you can find the source of bit(int row, int col)

Description

Bitboard containing a single set bit

License

Open Source License

Parameter

Parameter Description
row row of square to set
col col of square to set

Return

bitboard

Declaration

public static long bit(int row, int col) 

Method Source Code

//package com.java2s;
/*/*w ww  . ja  v a  2 s.  co  m*/
 * Copyright (c) 2014 Chris Welty.
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This file is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * For the license, see <http://www.gnu.org/licenses/gpl.html>.
 */

public class Main {
    /**
     * Bitboard containing a single set bit
     *
     * @param row row of square to set
     * @param col col of square to set
     * @return bitboard
     */
    public static long bit(int row, int col) {
        return 1L << square(row, col);
    }

    /**
     * Calc square index from row and col index
     *
     * @param row index of row
     * @param col index of col
     * @return square index
     */
    public static int square(int row, int col) {
        return row * 8 + col;
    }
}

Related

  1. bit(byte[] h, int i)
  2. bit(int a, int b)
  3. BIT(int x)
  4. bitArray2byte(boolean[] array)
  5. bitarrayShiftAndFill(byte[] data, int length, int shift, byte first, byte last)
  6. bitArrayToByte(byte[] bytes)