I was wondering if it's possible to set a double from two integers, say:
int i = 1;
int j = 2;
double l = i.j;
so hopefully have l set to 1.2.
I'm currently trying this with a loop, but nothing is coming of it:
for (int i = 0; i < 8; i++){
for(int l = 0; l < 8; l++){
double piece = i.l;
ChessSquare chessSquare = new ChessSquare(i, l, piece);
int[][] square = new int[i][l];
frame.add(chessSquare);
}
}
int i=1;
int j=2;
String s = i+"."+j;
double d = Double.parseDouble(s);
System.out.println(d);
How about this? I know String concat and stuffs will be pretty annoying(exceptions mainly), but certainly, this could help you out, if i & j are for sure gonna be numbers.
This should work, although I don't understand where a double comes into play in a chess game:
int i = 1;
int j = 2;
double piece = i + j / Math.pow(10.0 , String.valueOf(j).length())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With