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

 


Help: OASIS Mailing Lists Help | MarkMail Help

office message

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


Subject: Re: [office] Formula: test cases



An interesting example of how others have approved this problem is the functions in XPath 1.0.   Here's how James Clark describes the round() function:

"Function: number round(number)

The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is closest to positive infinity is returned. If the argument is NaN, then NaN is returned. If the argument is positive infinity, then positive infinity is returned. If the argument is negative infinity, then negative infinity is returned. If the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned. If the argument is less than zero, but greater than or equal to -0.5, then negative zero is returned."

I always liked that definition.  Very complete. It is just text, with no test suite, but the text is mainly a verbose English enumeration of text cases.  Why not rwrite it as:


"The round function returns the number that is closest to the argument and that is an integer. If there are two such numbers, then the one that is closest to positive infinity is returned.

Examples:

round(NaN) = NaN
round(Inf) = Inf
round (-Inf) = -Inf
round(0) = 0
round (-0) 0
round (0.25) = -0"

Isn't this just a difference of notation and one that is much easier to read?  Interestingly in other parts of XPath, explicit examples are given, such as in the definition of substring().

 If needed we could probably write a Python script that would take all of the test cases and generate English sentences for each one.  But is that an improvement?

-Rob


Patrick Durusau <patrick@durusau.net> wrote on 03/29/2007 12:48:50 PM:

> Bruce,
>
> Bruce D'Arcus wrote:
>
> >
> > On Mar 29, 2007, at 12:26 PM, Patrick Durusau wrote:
> >
> >>> This seems like a reasonable point, and the crux of the matter.
> >>>
> >> Well, a reasonable point but not really the crux of the matter.
> >
> >
> > By this I mean the central question is whether formulas constitute a  
> > special case of sorts that would justify the approach. That, it seems  
> > to me, *is* the crux of the matter. General rules only work for  
> > general cases.
> >
> Oh, OK, I stand corrected. Sorry, did not understand that to be your point.
>
> Hmmm, well I doubt this is the first time that formulas (or other math
> functions) have been specified. I will check with the usual suspects
> (standards bodies) and see what I can turn up. Most of that stuff tends
> to be unavailable online but I will see what I can turn up.
>
> Hope you are having a great day!
>
> Patrick
>
> PS: Would standards by mathematical associations count? Not ISO but
> certainly similar in character.
>
> --
> Patrick Durusau
> Patrick@Durusau.net
> Chair, V1 - Text Processing: Office and Publishing Systems Interface
> Co-Editor, ISO 13250, Topic Maps -- Reference Model
> Member, Text Encoding Initiative Board of Directors, 2003-2005
>
> Topic Maps: Human, not artificial, intelligence at work!
>
>



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