I am trying to figure this out:
double chiSquare = ((double)(hashtable.get(key).intValue()/noWords))/* * Math.log10((NO_DOCUMENTS/all.get(key)))*/;
if (key.equals("love")){
System.out.println(hashtable.get(key));
System.out.println(all.get(key));
System.out.println(noWords);
System.out.println(chiSquare);
System.out.println((double)1/841);
System.exit(0);
}
Why is it printing chiSquare, prints a zero, while printing 1/841 gives the double value?
The hashtable is of <String, Integer>
As @GregS indicated in his comment, an int divided by an int is an int.
Casting one of the numbers to a double will produce the output your desire.
Or, use the convenience method on Integer to convert it to a double: