home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!fmrco!fmrco!asherman
- From: asherman@laser.fmrco.com (Aaron Sherman)
- Subject: Re: *Another* embarrassingly simple question
- In-Reply-To: sondeen@isi.edu's message of 21 Jul 92 16:03:56 GMT
- Message-ID: <ASHERMAN.92Jul22172630@laser.fmrco.com>
- Sender: news@fmrco.uucp
- Reply-To: asherman@fmrco.COM
- Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
- References: <21982@venera.isi.edu>
- Date: Wed, 22 Jul 1992 22:26:30 GMT
- Lines: 29
-
-
- >>>>> sondeen@isi.edu (Jeff Sondeen) said:
-
- sondeen> How can I print a number as binary?
-
- # Int to binary string. Pass a number and the number of bits that
- # you want.
- sub itobs
- {
- local($num,$bits) = @_;
- local($i,$binstr);
-
- for($i=0;$i<$bits;$i++)
- {
- substr($binstr,0,0) = ($n & 1);
- $num >>= 1;
- }
- $binstr;
- }
-
-
-
- -AJS
-
- --
- --------
- Disclaimer: I am solely responsible for the content of this message.
- The views expressed here may not be the views of I-Kinetics, Fidelity,
- any of the Fidelity-owned corporations or my mother.
-