Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: reliably test integer size for portable bit-fiddling? (~0)

by wollmers (Scribe)
on Dec 09, 2014 at 08:46 UTC ( [id://1109695]=note: print w/replies, xml ) Need Help??


in reply to Re: reliably test integer size for portable bit-fiddling? (~0)
in thread reliably test integer size for portable bit-fiddling?

log(~0)/log(2)

Hmm, I tried a similar idea (get the index of the highest bit), but it failed. Now I remember:

helmut@w3:~$ perl -e 'print log(-1)/log(2),"\n";' Can't take log of -1 at -e line 1.

Thx, this is extremely fast and IMHO reliable, because it tests the capabilty directly.

Helmut "wollmers" Wollmersdorfer

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-24 14:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found