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