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

[SRFI 77] integer-length and integer-sqrt

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.

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


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:


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