Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] two questions

Expand Messages
  • merlyn@stonehenge.com
    ... nanambalasi I got two questions, first is there a way to add binary numbers? nanambalasi I mean we got two numbers nanambalasi 01100010 and nanambalasi
    Message 1 of 2 , Jun 3, 2004
      >>>>> "nanambalasi" == nanambalasi <okidan@...> writes:

      nanambalasi> I got two questions, first is there a way to add binary numbers?
      nanambalasi> I mean we got two numbers
      nanambalasi> 01100010 and
      nanambalasi> 11001001
      nanambalasi> how do we OR, XOR and ADD these binaries. Without converting it to
      nanambalasi> decimal then doing & operation and then back to binary.

      I don't know why you'd need to convert it to decimal. The number
      format of 0b01100010 works just fine as literals. If you are reading
      the data instead, pack "N", unpack "B*", $value works pretty well to
      convert it into a number (NOT decimal!).

      Probably what you want is:

      printf "%b\n", 0b01100010 & 0b11001001;

      Similarly, "|" for "or", "^" for "xor", and "+" for add.

      nanambalasi> Second question, I want to measure time taken for some operation, i
      nanambalasi> have
      nanambalasi> always used this method:

      See the DateTime modules in the CPAN.

      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
      See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Your message has been successfully submitted and would be delivered to recipients shortly.