Re: [prolog-standard] Re: log10/1, log/2, min/2, and max/2

From: Richard A. O'Keefe <>
Date: Fri, 17 Nov 2006 15:39:45 +1300 (NZDT)

Jan Wielemaker <>
        First of all, in practice min and max are rarely used with mixed types.

So what? That doesn't absolve us of the duty of getting them right.

        Second, most implementations providing unbounded integer
        arithmetic do not provide unbounded floats, so max(2<<10000,
        2.0) raises an error if we promote the floats.

That is a straw man argument. Who said anything about promoting floats?
The only alternatives being considered are
    - return wrong answers (apply floating-point contagion)
    - return exact answers (*compare* floats and bignums correctly
                            without *converting* either).
What you do is compare
    - signs first,
    - then scale (power of two),
    - then significands
so that no overflow, loss of precision, or other error is possible.

        If you leave it undefined, there is no problem. I can't see
        realistic scenarios where it matters.

There is always the possibility of making mixed mode min and max errors,
so that only
    max(integer, integer) -> integer
and max(float, float) -> float
are allowed.

prolog-standard mailing list
Received on Mon Jul 14 2008 - 13:01:02 EST

This archive was generated by hypermail 2.2.0 : Wed Sep 08 2010 - 23:28:17 EST