I'm trying to convert an array of chars to an array of doubles with each one between 0-1, so that a
would be 0
and z
would be 1
. Currently, I've thought of this method,
public static double[] charToDouble(char[] chars){
double[] doubles=new double[chars.length];
double one=1;
double twentySix=26;
double eachChar=one/twentySix;
for(int i=0; i<chars.length; i++){
int charNum=((int)input)-96;
doubles[i]=eachChar*charNum;
}
return doubles;
}
but a
would be converted to 1/26
instead of 0
.