From: Herve Bronnimann (hbr_at_[hidden])
Date: 2002-09-03 22:17:18
On Tue, Sep 03, 2002 at 02:01:31PM -0400, Rozental, Gennadiy wrote:
> In a sense all types used in numeric computation are "discreet". It's step
> that matter. Some will be happy with step equal 1. Some will need 1e-1000.
> Underlying type used to represent values in program we already abstracted as
> template parameter. So in this sense I do not see why int as internal
> parameter is worse then double.
It's different enough that std::numeric_limits has is_float to false for
int and true for double, and that the standard makes a distinction
between floating point types and integral types.
> Iterator concept could also be useful for intervals. Let say I want to
> compute am integral over some interval. Would not the iterator be of some
> help to implement the algorithm so it would use STL algorithms.
If you mean to step through the (floating point) interval to integrate,
I'm afraid it's a badly chosen example: your stepping by epsilon() will
take FOREVER. And the gain in precision will not be worth it.
> Since as I
> mentioned before all types are in fact discrete with the step equal to
> numeric_limits::epsilon(), it could be a natural step for iterator. I also
> should be possible define different step.
That would not work for the case of doubles. Principally, epsilon() is
only valid for floating point types, and values between 1.0 and 2.0
(excluded). And it's definitely too small for any kind of iteration
except on really small intervals. (Try 2^53 intermediate values...)
> So IMO I do not see to much differences between Interval and Range to
> justify to different classes. Though I my be missing something.
I beg to differ, for reasons above among others.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk