Hi,

>> I'm mostly using log2 to work out if numbers are a power of two and find
>> the highest bit that they have set.
>>
>> Is there a more robust way to do that in CHICKEN when using the numbers
>> egg and bignums?
> 
> It's probably better to do something like this:
> 
> (= (arithmetic-shift 1 (sub1 (integer-length x))) x)

Thanks for your help with this!

I've had some time over the last couple of days to play some more and
now it's working much better.


> Maybe we should consider including "first-bit-set" or "logcount" from
> SRFI-60, what do you think?  These would allow us to avoid constructing
> potential bignums just to check the lowest bit.  I initially decided
> against including SRFI-60 because it's such a huge grab-bag of
> procedures without much of a design behind it, and the worst part is
> that most of them have two names instead of one :(

I'm not sure. We seem to have things like integer-length already.
logcount sounds like a popcount implementation and I didn't find a use
for it in this particular case.
I agree that it's a big of a grab-bag.


Thanks for your help.



Regards,
@ndy

-- 
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to