summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorWilson P. Snyder II <unknown@perl.org>1998-11-30 00:00:00 +0000
committerJarkko Hietaniemi <jhi@iki.fi>1998-12-31 11:18:17 +0000
commit4f19785bce4da39a768aa6210f1f97ab4c0600dd (patch)
treed61c839a9780269b7b0766bad2487e8053caa5fd /pod
parent142393a6492fce5c4bb6f282b1ba1d8da7c0064b (diff)
downloadperl-4f19785bce4da39a768aa6210f1f97ab4c0600dd.tar.gz
REV2: Binary number support
To: perl5-porters@perl.org Message-ID: <199811301543.KAA15689@vulcan.maker.com> p4raw-id: //depot/cfgperl@2546
Diffstat (limited to 'pod')
-rw-r--r--pod/perldata.pod1
-rw-r--r--pod/perldelta.pod6
-rw-r--r--pod/perlfunc.pod6
3 files changed, 11 insertions, 2 deletions
diff --git a/pod/perldata.pod b/pod/perldata.pod
index 9e41c2c368..7b9a323338 100644
--- a/pod/perldata.pod
+++ b/pod/perldata.pod
@@ -245,6 +245,7 @@ integer formats:
.23E-10
0xffff # hex
0377 # octal
+ 0b111000 # binary
4_294_967_296 # underline for legibility
String literals are usually delimited by either single or double
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index aa3539be8a..bdcb7cf40c 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -40,6 +40,12 @@ maintenance versions.
=head1 Core Changes
+Binary numbers are now supported as literals, in s?printf formats, and
+C<oct()>:
+
+ $answer = 0b101010;
+ printf "The answer is: %b\n", oct("0b101010");
+
The length argument of C<syswrite()> is now optional.
Better 64-bit support -- but full support still a distant goal. One
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 300379f6d7..c78161141a 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -2237,8 +2237,9 @@ See the L</use> function, which C<no> is the opposite of.
=item oct
Interprets EXPR as an octal string and returns the corresponding
-value. (If EXPR happens to start off with C<0x>, interprets it as
-a hex string instead.) The following will handle decimal, octal, and
+value. (If EXPR happens to start off with C<0x>, interprets it as a
+hex string. If EXPR starts off with C<0b>, it is interpreted as a
+binary string.) The following will handle decimal, binary, octal, and
hex in the standard Perl or C notation:
$val = oct($val) if $val =~ /^0/;
@@ -3644,6 +3645,7 @@ In addition, Perl permits the following widely-supported conversions:
%X like %x, but using upper-case letters
%E like %e, but using an upper-case "E"
%G like %g, but with an upper-case "E" (if applicable)
+ %b an unsigned integer, in binary
%p a pointer (outputs the Perl value's address in hexadecimal)
%n special: *stores* the number of characters output so far
into the next variable in the parameter list