@
audreyeckman
Are you aware of the tutorial and reference sections at the top left of this page? There are example code snippets there, plus you should be able to find lots of stuff via Google. There is also
for a detailed technical view of every aspect of c++.
You could make use of my earlier advice to write an IsZero function:
const bool RPN::IsZero (const double Value, const double Precision) const;
Although it might be better in a larger scope - that is, maybe not in the RPN class.
And it could be further improved by writing a template so it can handle
float
and
long double
as well.
@
dhayden
Thanks for your as per usual great comments :+) With this part, though:
Consider 1e-20 / 1e-20. Should this be 1, or should it result in division by zero? |
Would that not be taken care of via the selection of the epsilon value? If one was doing some calculation involving the mass of an electron say, then one would select an epsilon value appropriate for that range of numbers. I guess there are situations where one wouldn't use an epsilon value at all: as in situations where it is valid to have both small and large numbers.
Maybe this all gets back to what we have discussed before: there is general advice, which is good for most things; then situations where the opposite is appropriate for those who know what they are doing.
As a side note, IIRC it was proposed that c++17 would have exact decimal numbers (finally, lots of other systems have had them for a long time). This would be particularly useful for currency applications, amongst other things.
Mind, I wonder if Dennis Ritchie might roll in his grave if people start using doubles in the control expressions of
for
loops :+D
Another thing c++11 has
std::nextafter
and
std::nexttoward
, which someone might find useful.