Boost logo

Boost :

From: dherring_at_[hidden]
Date: 2008-04-29 15:27:56

On Tue, 29 Apr 2008, John Maddock wrote:

> Folks I'm looking for some good names for some functions I'm on the brink of
> adding to Boost.Math (all in namespace boost::math::):
> T nextafter(T val, T dir)
> T next_greater(T val)
> T next_less(T val)

Given the first name is fixed, this is a reasonable family of names;
though dropping the underscore would increase consistency. However, there
is the ambiguity whether greater/less reference zero or infinity.

nextpositive() and nextnegative() might be clearer. Why does this remind
me of IEEE-754 rounding modes?

> T edit_distance(T a, T b)
> Returns the number of floating point representations between values a and b.
> So the questions are: can you think of any better names, or are these OK?
> And should edit_distance return a signed or absolute value?

I'm at a loss for a better name (representation_distance seems overly
verbose but interval_size might be ok), but do have a couple questions
about this function's behavior.

Why is the return value templated? Shouldn't it be some fixed diff_t? I
tentatively agree with the other comment that a signed distance is
preferable to unsigned.

Shouldn't this return the number of gaps, rather than the number of
representations? Consider the following examples

float x=1.0;
float y=2.0;
int d=edit_distance(x, y);
float z=x;
for(int i=0; i<d; i++)
// Does y==z?

for(int i=0; i<d/2; i++)
// Does y==(x+z)/2, given the right rounding mode?


Boost list run by bdawes at, gregod at, cpdaniel at, john at