[R6RS] Arithmetic nitpicks

William D Clinger will at ccs.neu.edu
Mon Jul 10 12:04:46 EDT 2006


Mike wrote:
> Two minor points, mainly for Will:
> 
> - Given the naming of procedures like `exact-length', shouldn't
>   `exact-integer-sqrt' be called `exact-sqrt'?

Yes.  I prefer exact-sqrt.

> - `exact-length' differs from Common Lisp's `integer-length' on
>   negative arguments.  Is this intentional?

I wouldn't go so far as to say it was intentional.

SRFI 60 doesn't really specify the behavior on
negative arguments, so I had to make something up.
What I made up is that exact-length returns the
number of bits required to represent the absolute
value.  That may be the most reasonable thing for
bignums, but it's inconsistent with the two's
complement semantics of Common Lisp and most of
the rest of SRFI 77.

>   The semantics of both don't make much sense to me: Common Lisp has
>   (integer-length -8) => 3 for no good reason I can see, even though
>   the two's complement representation of -8 requires 4 bits.  We have
>   (exact-length -8) => 4, but also (exact-length -9) => 4, even though
>   the two's complement representation of -9 requires 5 bits.  (At
>   least CL's notion increments at the right point.)  Shouldn't we
>   have:
> 
>   (exact-length i) => (exact-length (exact-not i)) for i < 0
> 
>   rather than
> 
>   (exact-length i) => (exact-length (exact- i)) for i < 0

Sounds good to me.  Unless someone objects, I will
make that change.

Will



More information about the R6RS mailing list