OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

office-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: RE: [office-comment] Error in FLOOR function specification


Dennis Hamilton scripsit:

> I think what is mistaken here, and perhaps in other places in OpenFormula,
> is the use of an operational, implementation-sounding definition when the
> definition of the mathematical behavior that is desired is perfectly clean
> and allows implementations to do whatever is appropriate that preserves
> the defined invariant.

The best, however, is in this case the enemy of the good.

> In particular, floor(x) is the largest integer not greater than x,
> ceiling(x) is the smallest integer not less than x.  Similarly, floor(x,p)
> is the largest integer multiple of p not greater than x and ceiling(x,p)
> is the smallest integer multiple of p not less than x.

That's the way it should be defined, yes.  But when x and p have
opposite signs, the result is undefined, and the standard needs
to take that into account.

As the C++ WG says:  "A standard is a contract between implementers and
users, to make it possible for users to write portable code. It's supposed
to say what implementers are permitted to do, what they're required to do,
and what users can and can't count on."

Now arguably it would be better to rewrite floor and ceiling completely
to provide the mathematical definition, and then provide exception
clauses for the p = 0 (same as p = 1 for positive x and p = -1 for
negative x) and opposite-sign cases.

But in the meantime, the existing definition of floor is wrong
as written, and that can be fixed by replacing "away from zero"
with "toward zero".  Please take the time to convince yourself
that this is true.

-- 
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
In computer science, we stand on each other's feet.  --Brian K. Reid




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]