[O] Fix floating point precision errors

This commit is contained in:
Hykilpikonna
2019-09-16 22:47:13 -04:00
parent bb4b34722f
commit c885137ed7
+5 -2
View File
@@ -65,8 +65,11 @@ export class GPAUtils
totalGPA += this.getGP(course);
});
// Get average GPA
return {gpa: totalGPA / courses.length, accurate: accurate};
// Get average GPA, round to two decimal places
let gpa = Math.round(totalGPA / courses.length * 100) / 100;
// Return results
return {gpa: gpa, accurate: accurate};
}
/**