Re: [xsl] ceiling(), floor(), and data types

Subject: Re: [xsl] ceiling(), floor(), and data types
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Sep 2017 14:23:57 -0000
Answering "why" questions about specs is notoriously difficult. Do you want a
historical exposition of how and when the decisions were made, or do you
simply want an opinion as to why a reasonable designer might have chosen to do
it that way?

Looking at the history, the WG discussed the point on 5 Dec 2001. The minutes
record:

Add issue: what do float, ceiling, and round return? Is it always a
   decimal, or the same type as their argument (are they overloaded), or ...

   Note that xf:substring("foo", round(1.5)) would require an explicit cast
   if round returns a double.

   Add issue: what do float, ceiling, and round return if the argument is
   NaN, etc.?

Important context here is that ceiling() and floor() were present in XPath 1.0
when there was only one numeric data type (effectively xs:double). That meant
that in XPath 1.0, ceiling(NaN) returned NaN, and perhaps the WG wanted to
keep it that way.

Michael Kay
Saxonica


> On 14 Sep 2017, at 11:30, Birnbaum, David J djbpitt@xxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Dear XSL List,
>
> I was surprised to learn today that ceiling() and floor() do not
obligatorily return a value of type xs:integer. If I've understood correctly
that they necessarily return a value that a human would consider an integer,
is there a reason that other return types are permitted?
>
> Thanks,
>
> David

Current Thread