Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Most Significant Set Bit

by Danny (Chaplain)
on Mar 15, 2024 at 23:03 UTC ( [id://11158298]=note: print w/replies, xml ) Need Help??


in reply to Re: Most Significant Set Bit
in thread Most Significant Set Bit

I timed those two functions along with the following:
sub by_string { my $n = shift; return length(sprintf "%b", $n) - 1; }
I tested with high bits using int rand(2**64), medium bits int rand(2**32) and lower bits int rand(2**16) for 1e6 iterations.
log linear sprintf 0.2917 0.4427 0.3370 avg_sig=62 0.2786 2.8430 0.3056 avg_sig=30 0.2826 4.1060 0.2986 avg_sig=14

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11158298]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2026-01-16 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (118 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.