From 4f19785bce4da39a768aa6210f1f97ab4c0600dd Mon Sep 17 00:00:00 2001 From: "Wilson P. Snyder II" Date: Mon, 30 Nov 1998 00:00:00 +0000 Subject: REV2: Binary number support To: perl5-porters@perl.org Message-ID: <199811301543.KAA15689@vulcan.maker.com> p4raw-id: //depot/cfgperl@2546 --- sv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sv.c') diff --git a/sv.c b/sv.c index fdeed681f5..6d900cee0e 100644 --- a/sv.c +++ b/sv.c @@ -4645,6 +4645,10 @@ sv_vcatpvfn(SV *sv, const char *pat, STRLEN patlen, va_list *args, SV **svargs, base = 10; goto uns_integer; + case 'b': + base = 2; + goto uns_integer; + case 'O': intsize = 'l'; /* FALL THROUGH */ @@ -4700,6 +4704,14 @@ sv_vcatpvfn(SV *sv, const char *pat, STRLEN patlen, va_list *args, SV **svargs, if (alt && *eptr != '0') *--eptr = '0'; break; + case 2: + do { + dig = uv & 1; + *--eptr = '0' + dig; + } while (uv >>= 1); + if (alt && *eptr != '0') + *--eptr = '0'; + break; default: /* it had better be ten or less */ do { dig = uv % base; -- cgit v1.2.1