What would be the easiest way to display a number as dual / binary number?
For example: 29 is to be displayed as 11101.
In PHP this would work:
but not so in Perl.
Any idea?
Detlef Lindenthal
On Mar 4, 2005, at 6:28 AM, Detlef Lindenthal wrote:
What would be the easiest way to display a number as dual / binary
number?
For example: 29 is to be displayed as 11101.
In PHP this would work:
but not so in Perl.
Any idea?
First, I would convert the number to a string of hex digits using
sp
On Fri, 04 Mar 2005 12:28:43 +0100, Detlef Lindenthal wrote:
>What would be the easiest way to display a number as dual / binary number?
>For example: 29 is to be displayed as 11101.
>
>
>In PHP this would work:
>printf ("%b", 29);
>?>
>
>but not so in Perl.
>Any idea?
What version of Perl are yo
Bart Lateur wrote:
"%b" works in perl5.8.x, and,
judging by the "perldoc -f sprintf" for 5.6.1, in 5.6.1 too.
This is what I was looking for.
My MacPerl version number was 5.2.0r4; I just downloaded
MacPerl 5.6.1r2
for MacOS9.2 and found that printf "%b" ... works.
I also downloaded
Mac-
At 14:54 +0100 2005.03.04, Detlef Lindenthal wrote:
>I also downloaded
> Mac-Carbon 0.71
>for MacOSX; unfortunately I could not find an application
>nor a make...-how-to.
You need the Dev or Xcode Tools installed and up to date for your version
of Mac OS X. If you've got that, a simple:
Chris Nandor wrote:
At 14:54 +0100 2005.03.04, Detlef Lindenthal wrote:
I also downloaded
Mac-Carbon 0.71
for MacOSX; unfortunately I could not find an application
nor a make...-how-to.
You need the Dev or Xcode Tools installed and up to date for your version
of Mac OS X. If you've got
At 20:40 +0100 2005.03.04, Detlef Lindenthal wrote:
> ... obviously did work; on the other hand the result does not seem to be
>what I had expected: some MacPerl.app running on MacOSX. Also after reading
>the
>README file (after renaming it to README.pod and reading it from Shuck on
>OS9) the en
You can use unpack.
Here is an example from MacOS X rather than macperl, but it should work
the same way.
% perl -e 'print unpack("B*", chr(29)), "\n"'
00011101
note that in the context of unpack, values always seem to be treated as
strings; that is
% perl -e 'print unpack("B*", 29), "\n"'
00110