[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 369bcf32 3/4: Assert another precondition
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 369bcf32 3/4: Assert another precondition |
Date: |
Fri, 13 May 2022 05:10:14 -0400 (EDT) |
branch: master
commit 369bcf324175f99d7ab9f9621cdeba777a9755d6
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Assert another precondition
No one pays $1.01 for $1 of insurance.
This precondition helps to establish a broad range within which integer
arithmetic cannot overflow.
---
ul_utilities.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ul_utilities.cpp b/ul_utilities.cpp
index 03009f27..e6c51d0f 100644
--- a/ul_utilities.cpp
+++ b/ul_utilities.cpp
@@ -111,7 +111,9 @@ currency rate_times_currency
// illustrative examples of this precondition's effect.
constexpr int radix {100'000'000};
// Premium rate and specified amount are nonnegative by their nature.
+ // Premium rate cannot plausibly exceed unity.
LMI_ASSERT(0.0 <= rate);
+ LMI_ASSERT( rate <= 1.0);
LMI_ASSERT(C0 <= amount);
// Do not save and restore prior rounding direction, because lmi
// generally expects rounding to nearest everywhere.