Skip to main content
8 events
when toggle format what by license comment
Oct 15, 2017 at 14:01 comment added wvxvw (ash 1 (integer-length n)) is the same as (expt 2 (integer-length n)), though SBCL will probably figure this out on its own.
Jan 11, 2017 at 14:54 comment added Vatine @Renzo In this specific case, you could actually use - instead of logxor, but I'd probably do it with logxor, as it's more clearly bit manipulation.
Jan 11, 2017 at 14:53 comment added Vatine @GustavBertram For "number of digits of non-negative number", you could use (1+ (floor (log n <base>))) or (ceiling (log (1+ n) <base)), with a slight preference for the latter, as it sanely handles n == 0.
Jan 10, 2017 at 14:11 vote accept Gustav Bertram
Jan 10, 2017 at 14:11 comment added Gustav Bertram Oh man, I had gotten so close to this. I was stuck on (ceiling (log n 2)) instead of integer-length, which obviously fails on some edge cases.
Jan 10, 2017 at 14:00 history edited Renzo CC BY-SA 3.0
added 102 characters in body
Jan 10, 2017 at 14:00 comment added Rainer Joswig that's a nice answer
Jan 10, 2017 at 13:56 history answered Renzo CC BY-SA 3.0