Square extension type

A square of the chessboard.

The square is represented with an integer ranging from 0 to 63, using a little-endian rank-file mapping (LERF):

 8 | 56 57 58 59 60 61 62 63
 7 | 48 49 50 51 52 53 54 55
 6 | 40 41 42 43 44 45 46 47
 5 | 32 33 34 35 36 37 38 39
 4 | 24 25 26 27 28 29 30 31
 3 | 16 17 18 19 20 21 22 23
 2 | 8  9  10 11 12 13 14 15
 1 | 0  1  2  3  4  5  6  7
   -------------------------
     a  b  c  d  e  f  g  h

See also:

on
Implemented types
Available extensions

Constructors

Square(int value)
Gets the chessboard Square from a square index between 0 and 63.
const
Square.fromCoords(File file, Rank rank)
Gets a Square from its file and rank.
factory
Square.fromName(String algebraic)
Gets a Square from its name in algebraic notation.
factory

Properties

address Pointer<Never>

Available on int, provided by the IntAddress extension

The memory address of the underlying data.
getter/setter pair
bitLength int
Returns the minimum number of bits required to store this integer.
no setterinherited
file File
The file of the square on the board.
no setter
hashCode int
Returns a hash code for a numerical value.
no setterinherited
isEven bool
Returns true if and only if this integer is even.
no setterinherited
isFinite bool
Whether this number is finite.
no setterinherited
isInfinite bool
Whether this number is positive infinity or negative infinity.
no setterinherited
isNaN bool
Whether this number is a Not-a-Number value.
no setterinherited
isNegative bool
Whether this number is negative.
no setterinherited
isOdd bool
Returns true if and only if this integer is odd.
no setterinherited
name String
Unique identifier of the square, using pure algebraic notation.
no setter
rank Rank
The rank of the square on the board.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sign int
Returns the sign of this integer.
no setterinherited
toJS JSNumber

Available on num, provided by the NumToJSExtension extension

Converts this num to a JSNumber.
no setter
value int
final

Methods

abs() int
Returns the absolute value of this integer.
inherited
ceil() int
Returns this.
inherited
ceilToDouble() double
Returns this.toDouble().
inherited
clamp(num lowerLimit, num upperLimit) num
Returns this num clamped to be in the range lowerLimit-upperLimit.
inherited
compareTo(num other) int
Compares this to other.
inherited
floor() int
Returns this.
inherited
floorToDouble() double
Returns this.toDouble().
inherited
gcd(int other) int
Returns the greatest common divisor of this integer and other.
inherited
modInverse(int modulus) int
Returns the modular multiplicative inverse of this integer modulo modulus.
inherited
modPow(int exponent, int modulus) int
Returns this integer to the power of exponent modulo modulus.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offset(int delta) Square?
Returns the square offset by delta.
remainder(num other) num
The remainder of the truncating division of this by other.
inherited
round() int
Returns this.
inherited
roundToDouble() double
Returns this.toDouble().
inherited
toDouble() double
This number as a double.
inherited
toInt() int
Truncates this num to an integer and returns the result as an int.
inherited
toRadixString(int radix) String
Converts this int to a string representation in the given radix.
inherited
toSigned(int width) int
Returns the least significant width bits of this integer, extending the highest retained bit to the sign. This is the same as truncating the value to fit in width bits using an signed 2-s complement representation. The returned value has the same bit value in all positions higher than width.
inherited
toString() String
Returns a string representation of this integer.
inherited
toStringAsExponential([int? fractionDigits]) String
An exponential string-representation of this number.
inherited
toStringAsFixed(int fractionDigits) String
A decimal-point string-representation of this number.
inherited
toStringAsPrecision(int precision) String
A string representation with precision significant digits.
inherited
toUnsigned(int width) int
Returns the least significant width bits of this integer as a non-negative number (i.e. unsigned representation). The returned value has zeros in all bit positions higher than width.
inherited
truncate() int
Returns this.
inherited
truncateToDouble() double
Returns this.toDouble().
inherited
xor(Square other) Square
Return the bitwise XOR of the numeric square representation.

Operators

operator %(num other) num
Euclidean modulo of this number by other.
inherited
operator &(int other) int
Bit-wise and operator.
inherited
operator *(num other) num
Multiplies this number by other.
inherited
operator +(num other) num
Adds other to this number.
inherited
operator -(num other) num
Subtracts other from this number.
inherited
operator /(num other) double
Divides this number by other.
inherited
operator <(num other) bool
Whether this number is numerically smaller than other.
inherited
operator <<(int shiftAmount) int
Shift the bits of this integer to the left by shiftAmount.
inherited
operator <=(num other) bool
Whether this number is numerically smaller than or equal to other.
inherited
operator ==(Object other) bool
Test whether this value is numerically equal to other.
inherited
operator >(num other) bool
Whether this number is numerically greater than other.
inherited
operator >=(num other) bool
Whether this number is numerically greater than or equal to other.
inherited
operator >>(int shiftAmount) int
Shift the bits of this integer to the right by shiftAmount.
inherited
operator >>>(int shiftAmount) int
Bitwise unsigned right shift by shiftAmount bits.
inherited
operator ^(int other) int
Bit-wise exclusive-or operator.
inherited
operator unary-() int
Return the negative value of this integer.
inherited
operator |(int other) int
Bit-wise or operator.
inherited
operator ~() int
The bit-wise negate operator.
inherited
operator ~/(num other) int
Truncating division operator.
inherited

Static Methods

parse(String algebraic) Square?
Parses a square name in algebraic notation.
override

Constants

a1 → const Square
a2 → const Square
a3 → const Square
a4 → const Square
a5 → const Square
a6 → const Square
a7 → const Square
a8 → const Square
b1 → const Square
b2 → const Square
b3 → const Square
b4 → const Square
b5 → const Square
b6 → const Square
b7 → const Square
b8 → const Square
c1 → const Square
c2 → const Square
c3 → const Square
c4 → const Square
c5 → const Square
c6 → const Square
c7 → const Square
c8 → const Square
d1 → const Square
d2 → const Square
d3 → const Square
d4 → const Square
d5 → const Square
d6 → const Square
d7 → const Square
d8 → const Square
e1 → const Square
e2 → const Square
e3 → const Square
e4 → const Square
e5 → const Square
e6 → const Square
e7 → const Square
e8 → const Square
f1 → const Square
f2 → const Square
f3 → const Square
f4 → const Square
f5 → const Square
f6 → const Square
f7 → const Square
f8 → const Square
g1 → const Square
g2 → const Square
g3 → const Square
g4 → const Square
g5 → const Square
g6 → const Square
g7 → const Square
g8 → const Square
h1 → const Square
h2 → const Square
h3 → const Square
h4 → const Square
h5 → const Square
h6 → const Square
h7 → const Square
h8 → const Square
values → const List<Square>
All squares on the chessboard, from a1 to h8.