[O] Fix floating point precision errors
This commit is contained in:
@@ -65,8 +65,11 @@ export class GPAUtils
|
|||||||
totalGPA += this.getGP(course);
|
totalGPA += this.getGP(course);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get average GPA
|
// Get average GPA, round to two decimal places
|
||||||
return {gpa: totalGPA / courses.length, accurate: accurate};
|
let gpa = Math.round(totalGPA / courses.length * 100) / 100;
|
||||||
|
|
||||||
|
// Return results
|
||||||
|
return {gpa: gpa, accurate: accurate};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user