Leser: 2
|< 1 2 >| | 15 Einträge, 2 Seiten |
print unpack("b*", pack("L", 3)); # 11000000000000000000000000000000
print unpack("B*", pack("L", 3));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
use strict;
use warnings;
sub bitstring {
return undef unless $_[0] =~ /^\d*$/;
my $bstr = unpack("B*", pack("L",$_[0]));
sprintf ( "%s%s%s%s", substr($bstr, 24, 8),
substr($bstr, 16, 8),
substr($bstr, 8, 8),
substr($bstr, 0, 8));
}
print "21098765432109876543210987654321\n";
print bitstring(3)."\n";
print bitstring(254)."\n";
print bitstring(255)."\n";
print bitstring(256)."\n";
print bitstring(65534)."\n";
print bitstring(65535)."\n";
print bitstring(65536)."\n";
1
2
3
4
5
6
7
8
# zeichenweise
my $x = "abCDe";
my $y = join('', reverse split //, $x);
print "zeichenweise: $y\n";
# blockweise
$y = join('', reverse split /(..)/, $x); # verbesserungsfähig
print "blockweise: $y\n";
|< 1 2 >| | 15 Einträge, 2 Seiten |