Re: word size
by BrowserUk (Patriarch) on Sep 08, 2005 at 03:22 UTC
|
You might find the information available from Config useful. Here's a list of keys with 'size' in the the name:
use Config;;
printf "$_ => %s", $Config{ $_ }||'n/a' for grep /size/i, keys %Config
+;;
charsize => 1
d_chsize => define
doublesize => 8
fpossize => 8
gidsize => 4
i16size => 2
i32size => 4
i64size => 8
i8size => 1
intsize => 4
ivsize => 4
longdblsize => 10
longlongsize => 8
longsize => 4
lseeksize => 8
nvsize => 8
ptrsize => 4
shortsize => 2
sig_size => 27
sizesize => 4
sizetype => size_t
socksizetype => int
ssizetype => int
u16size => 2
u32size => 4
u64size => 8
u8size => 1
uidsize => 4
uvsize => 4
intsize & ivsize are probably the most relevant for your purpose.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] [select] |
|
|
Ahh...but how much fun would that be? This was, after all, meant to be a CUFP; something that originated in some assembly I was working on. How often do you see the bit operations put to use? :o)
| [reply] |
|
|
The problem is, that all those sizes are in bytes, not bits.
I'm not sure how you can compute the size of something in bits using Config, as it doesn't tell the number of bits in characters.
Maybe you could use something like ivsize/i32size*32.
| [reply] |
|
|
Hmm. Now I know there have been machines with 6-bit bytes, and (maybe) 9-bit bytes, in the dark distant past, but I'm not aware of any remotely modern cpu that doesn't use 8-bit bytes?
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] |
|
|
|
|
|
Re: word size
by ambrus (Abbot) on Sep 08, 2005 at 21:25 UTC
|
$bits = length(unpack("B*",pack("J")));
| [reply] [d/l] |
Re: word size
by chanio (Priest) on Sep 11, 2005 at 04:24 UTC
|
perl -e'
use strict;
my $bina;
my $count;
my $bits = ~(64);
while ($bits)
{
prbit($bits);
$bits >>= 1;
$count++;
}
sub prbit
{
my $bi=shift;
$bina.=($bi%2)? "0":"1";
}
$bina=reverse($bina);
print "$bina\n$count bit words are being used.\n";'
__OUTPUTS__
00000000000000000000000001000000
32 bit words are being used.
| [reply] [d/l] |
|
|
Ahh..at least someone is going to humor me! We find ourselves with a fun base_10 to base_2 conversion.
GOT_VOTES:{($collin{votes} > 0) ? do{$chanio++;last} : goto GOT_VOTES}
:o) | [reply] [d/l] |
|
|
It was my homework :) (THXS 4 voting me, here's mine in exchange :) )
| [reply] |