[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Group quotes, part deux
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] Group quotes, part deux |
Date: |
Fri, 20 May 2016 02:18:11 +0200 |
On Thu, 19 May 2016 21:46:50 +0000 Greg Chicares <address@hidden> wrote:
GC> + double const average =
1000*totals_.total(col)/totals_.total(col - 1);
GC> + average_text = '$' + ledger_format(average, f);
GC>
GC> Validated.
I'm having second thoughts about the first line... When writing it, I
decided that testing for totals_.total(col-1) being 0 was unnecessary
because this happens iff the column is hidden anyhow -- this is exactly the
same condition as is used for hiding it. So while this division would
produce a NaN in this case, it doesn't matter because the result is not
shown.
However it doesn't seem impossible that ledger_format() might decide to
complain if it's passed a NaN in the future, even if it doesn't do it now.
And, even now, it's useless to format something that we know we're not
going to use.
So while this is not going to change the user-visible behaviour, and so
does _not_ require making another lmi release candidate IMHO, what about
applying this patch just to avoid any possibility of a problem here in the
future:
---------------------------------- >8 --------------------------------------
diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index f655ed0..f17d066 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -1355,8 +1355,12 @@ void
group_quote_pdf_generator_wx::output_aggregate_values
// We can rely on the face amount column corresponding to this
// premium just preceding it because the way we display the
// averages wouldn't make sense otherwise.
- double const average =
1000*totals_.total(col)/totals_.total(col - 1);
- average_text = '$' + ledger_format(average, f);
+ double const face_amount = totals_.total(col - 1);
+ if(face_amount != 0)
+ {
+ double const average = 1000*totals_.total(col)/face_amount;
+ average_text = '$' + ledger_format(average, f);
+ }
break;
}
---------------------------------- >8 --------------------------------------
Sorry for changing my mind again, I probably should have proposed this
version from the beginning.
VZ
- Re: [lmi] Group quotes, part deux, (continued)
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/17
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/13
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/18
- Re: [lmi] Group quotes, part deux, Vadim Zeitlin, 2016/05/18
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/18
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/19
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/19
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/19
- Re: [lmi] Group quotes, part deux,
Vadim Zeitlin <=
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/19
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/19
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/20
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/20
- Re: [lmi] Group quotes, part deux, Vadim Zeitlin, 2016/05/20
- Re: [lmi] Group quotes, part deux, Vadim Zeitlin, 2016/05/19
- Re: [lmi] Group quotes, part deux, Greg Chicares, 2016/05/19