Created attachment 31 [details] The 8th laptop has better spec than the 2nd laptop Overview: Sorting by performance do not sort the data in the correct order Steps to Reproduce: 1) Input value(s) to any textfield in the recommendation panel (I inputted "Acer" in the Brand textfield) 2)Choose the Sort By Performance option 3)Press Submit button Actual Results: The data is sorted in incorrect order, some laptops with weaker CPU and GPU have been arranged ahead of those with stronger CPU and GPU Expected Results: The array list displayed should be arranged according to their hardware spec Build Date & Hardware: Build 2019-11-15 on Mac OS 10.14.5 & Windows 10
Debug steps: 1) reproduced the bug as mentioned 2) print out the rating index of each data (which affects the order of the data) Observations: Most data get the 1.0 rating from the formula we designed, so that the rating cannot separate the data far enough to obtain a result with correct order. The following formula should generate different result but it did not double rating1 = i5 + 1080Ti = (5*1080)/5350 = 1.0 double rating2 = i5 + 1070Ti = (5*1070)/5350 = 1.0 Suggested solution: We should be careful of the base in the formula, the hardcoded base rating denominator 5350 is declared in integer type, so the result is always in integer. We can change the code to double rating = (cpuRating * gpuRating) / 5350.0; So that the type of variables in this formula is unified as double. It should gives out slight difference in each data for correct sorting.
Created attachment 32 [details] bad code lines