[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numerical conditioning MAGNITUDE and /

This page is part of the web mail archives of SRFI 77 from before July 7th, 2015. The new archives for SRFI 77 contain all messages, not just those from before July 7th, 2015.

 | From: William D Clinger <will@xxxxxxxxxxx>
 | Date: Wed, 21 Jun 2006 09:29:44 -0400
 | Aubrey Jaffer wrote:
 | ...
 | > Does SRFI-77 (or R5RS) mandate that floating-point procedures
 | > work for arguments generating the full range of possible outputs?
 | No.  Neither mandates that ... implementations
 | of the standard procedures be of high quality.

R5RS Section 6.2.6 "Numerical Input and Output" places a stringent
constraint on the quality of NUMBER->STRING:

     If Z is inexact, the radix is 10, and the above expression can be
     satisfied by a result that contains a decimal point, then the
     result contains a decimal point and IS EXPRESSED USING THE
     MINIMUM NUMBER OF DIGITS (exclusive of exponent and trailing
     [howtoread]; otherwise the format of the result is unspecified.

The operations for computing complex MAGNITUDE and / are:

magnitude	flonum operations
	 sum  product quotient abs  <
naive:	  1	 2	 0	0   0
correct:  1	 2	 1	2   1

    /		flonum operations
	 sum  product quotient abs  <
naive:	  3	 6	 2	0   0
correct:  3	 3	 3	2   1

Floating-point ABS involves just flipping one bit; it should be very

The correct versions are unlikely to be much slower than naive ones;
correct-/ is perhaps faster.  So the arguments for implementing these
procedures incorrectly are weak.