On 5/17/07, Tom Lane <[EMAIL PROTECTED]> wrote:
Andrew Hammond <[EMAIL PROTECTED]> writes:
> Yet another potential addition to the family of operators. Some guy
> was asking for it on IRC so...
> CREATE OR REPLACE FUNCTION interval_over_interval(interval, interval)
> RETURNS float STRICT IMMUTABLE LANGUAGE sql AS $$
> SELECT extract(epoch from $1)::float / extract(epoch from $2);
What are the grounds for defining it that way rather than some other
The only alternative that came to mind when I wrote it was using a numeric
instead of float. I couldn't see why a numeric with some arbitrary precision
/ scale was particularly better than just using a double precision. There's
already an interval_div function in the catalog which take an interval and a
double precision and returns an interval, so using floating point math
already has precedent. I figured that if I went with numeric, I'd also have
to have a pretty good reason to change the existing operator or it'd
inconsistent. Since float (without parameters) is both shorter to type and
appears to be the same as double precision (at least according to the docs),
my innate lazy streak went that way.
Am I missing something obvious?