[SRFI 77] integer-length and integer-sqrt
Jens Axel Søgaard 06 Oct 2005 15:54 UTC
Thanks for a very interesting number srfi. Efficient
(and portable) arithmetic in Scheme has been on my wish
list for a long time.
I propose adding the following two operations on integers.
The first is INTEGER-LENGTH from CLHS
<http://clhs.lisp.se/Body/f_intege.htm>
which returns the number of bits needed to represent a given
integer in binary two's-complement format. Although it
is possible to define INTEGER-LENGTH as a library function,
it will be more efficient as a primitive, since it can
exploit the internal representation of an integer.
The second is INTEGER-SQRT, which is discussed here:
<http://groups.google.com/group/comp.lang.scheme/browse_frm/thread/dc06e91e306cf488/a9cf92f425bb3db1?lnk=st&q=lucier+integer-sqrt&rnum=1&hl=en#a9cf92f425bb3db1>
I consider INTEGER-SQRT just as natural an operation as GCD and LCM
when it comes to number theoretical calculations. But this may be
a matter of taste.
--
Jens Axel Søgaard