Double division behaving wrongly

后端 未结 4 1289
旧巷少年郎
旧巷少年郎 2020-11-30 15:51

I have a HashMap called List wordFreqMap whose size is 234

wordFreqMap = {radiology         


        
4条回答
  •  忘掉有多难
    2020-11-30 16:29

    You're performing an integer division and then type casting:

    tf = (double) ( word.getValue() / noOfTerms );
                    ^-----integer division----^
    

    Type cast one of the elements in the division to convert into a floating point division:

    tf = ((double)word.getValue()) / noOfTerms;
    

提交回复
热议问题