home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!sun-barr!apple!news.oc.com!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: *Another* embarrassingly simple question
- Message-ID: <1992Jul23.032422.19442@news.eng.convex.com>
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Nntp-Posting-Host: pixel.convex.com
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- Organization: CONVEX Realtime Development, Colorado Springs, CO
- References: <21982@venera.isi.edu>
- Date: Thu, 23 Jul 1992 03:24:22 GMT
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 17
-
- From the keyboard of sondeen@isi.edu (Jeff Sondeen):
- :How can I print a number as binary? What I want is
- : $num = 5;
- : print "%4b", $num; # but it doesn't give me 0101
- : ^^^
- : wishfull thinking
-
- Use:
-
- print unpack('B*', pack('N',$number))
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
-
-
- It's all magic. :-) --Larry Wall in <7282@jpl-devvax.JPL.NASA.GOV>
-