Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: built in function for binary division

by Kenosis (Priest)
on Jan 11, 2013 at 05:31 UTC ( #1012795=note: print w/replies, xml ) Need Help??

in reply to built in function for binary division

Do you mean something like the following?

use strict; use warnings; my $quotient = 0b10010110 / 0b1111; # 150 / 15 print sprintf '%b', $quotient; # prints 1010 (decimal 10)

Replies are listed 'Best First'.
Re^2: built in function for binary division
by ghosh123 (Monk) on Jan 11, 2013 at 05:44 UTC

    Hi Kenosis,

    Yes, this is what I meant. Is it possible to do by any built-in perl function ? Else any hint to achieve that ?

      You can work with binary numbers as shown, viz., by preceding the number with 0b, performing the operation, and then formatting the result using sprintf.

      Were you thinking of some other binary math function?

        Hi Kenosis

        Yes I was looking for some binary math subroutine for this, but what you have shown by preceding 0b is also fine.
        Thank you !!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012795]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2018-09-23 19:38 GMT
Find Nodes?
    Voting Booth?
    Eventually, "covfefe" will come to mean:

    Results (191 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!