Round to nearest hundredth decimal place
This commit is contained in:
parent
8b72c9df74
commit
3dadf20dbf
@ -117,7 +117,7 @@
|
||||
|
||||
<footer>
|
||||
<p>Created by <a href="https://haothitran.com">Hao Tran</a>.</p>
|
||||
<p>Note: Calculations are rounded to the nearest tenth decimal. As such, there may sometimes be issues of rounding error.</p>
|
||||
<p>Note: Calculations are rounded to the nearest hundredth decimal. As such, there may sometimes be issues of rounding error.</p>
|
||||
</footer>
|
||||
</body>
|
||||
<script src="scripts/calculator.js"></script>
|
||||
|
@ -23,17 +23,17 @@ function calculator() {
|
||||
|
||||
// calculate pro rata
|
||||
if(document.getElementById('calcProRata').checked) {
|
||||
var earnedFactor = Math.round(((forceDays / termDays) + Number.EPSILON)*1000)/1000;
|
||||
var unearnedFactor = Math.round(((remainingDays / termDays) + Number.EPSILON)*1000)/1000;
|
||||
var earnedFactor = Math.round(((forceDays / termDays) + Number.EPSILON)*100)/100;
|
||||
var unearnedFactor = Math.round(((remainingDays / termDays) + Number.EPSILON)*100)/100;
|
||||
// calculate short rate
|
||||
}else if(document.getElementById('calcShortRate').checked) {
|
||||
var earnedFactor = Math.round(((1 - ((remainingDays / termDays ) * 0.9)) + Number.EPSILON)*1000)/1000;
|
||||
var unearnedFactor = Math.round((((remainingDays / termDays) * 0.9) + Number.EPSILON)*1000)/1000;
|
||||
var earnedFactor = Math.round(((1 - ((remainingDays / termDays ) * 0.9)) + Number.EPSILON)*100)/100;
|
||||
var unearnedFactor = Math.round((((remainingDays / termDays) * 0.9) + Number.EPSILON)*100)/100;
|
||||
}
|
||||
|
||||
// calculate premiums
|
||||
var earnedPremium = Math.round(((totalPremium * earnedFactor) + Number.EPSILON)*1000)/1000;
|
||||
var unearnedPremium = Math.round(((totalPremium * unearnedFactor) + Number.EPSILON)*1000)/1000;
|
||||
var earnedPremium = Math.round(((totalPremium * earnedFactor) + Number.EPSILON)*100)/100;
|
||||
var unearnedPremium = Math.round(((totalPremium * unearnedFactor) + Number.EPSILON)*100)/100;
|
||||
|
||||
// calculate breakdown
|
||||
var calcBreak = +breakDO + +breakEO + +breakCyber + +breakLEI + +breakCGL + +breakProperty + +breakEB;
|
||||
|
Loading…
x
Reference in New Issue
Block a user