ó
BwLc           @   sY   d  Z  d d d d d g Z d d l Td „  Z d	 „  Z d
 „  Z d „  Z e d „ Z d S(   s   $Id$t
   ceil_shiftt   ceil_divt	   floor_divt
   exact_log2t	   exact_diviÿÿÿÿ(   t   *c         C   s¥   t  |  t t f ƒ s, t  | t t f ƒ rW t d t |  ƒ j t | ƒ j f ƒ ‚ n  |  d k ro | d k su t ‚ d | >d } |  | @r™ |  | ?d S|  | ?Sd S(   sÏ   Return ceil(n / 2**b) without performing any floating-point or division operations.

    This is done by right-shifting n by b bits and incrementing the result by 1
    if any '1' bits were shifted out.
    s&   unsupported operand type(s): %r and %ri    l    i   N(   t
   isinstancet   intt   longt	   TypeErrort   typet   __name__t   AssertionError(   t   nt   bt   mask(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/Util/_number_new.pyR        s    ,+
c         C   s‚   t  |  t t f ƒ s, t  | t t f ƒ rW t d t |  ƒ j t | ƒ j f ƒ ‚ n  t |  | ƒ \ } } | rz | d S| Sd S(   sD   Return ceil(a / b) without performing any floating-point operations.s&   unsupported operand type(s): %r and %ri   N(   R   R   R   R	   R
   R   t   divmod(   t   aR   t   qt   r(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/Util/_number_new.pyR   0   s    ,+c         C   sp   t  |  t t f ƒ s, t  | t t f ƒ rW t d t |  ƒ j t | ƒ j f ƒ ‚ n  t |  | ƒ \ } } | S(   Ns&   unsupported operand type(s): %r and %r(   R   R   R   R	   R
   R   R   (   R   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/Util/_number_new.pyR   <   s    ,+c         C   sÑ   t  |  t t f ƒ s4 t d t |  ƒ j f ƒ ‚ n  t |  ƒ } | d k r[ t d ƒ ‚ n  d } xI | d k r¬ | d @r• | d k r• t d ƒ ‚ n  | d 7} | d L} qd W| d 8} |  d | >k sÍ t ‚ | S(   s~   Find and return an integer i >= 0 such that num == 2**i.

    If no such integer exists, this function raises ValueError.
    s   unsupported operand type: %ri    s/   cannot compute logarithm of non-positive numberi   s   No solution could be foundl    (   R   R   R   R	   R
   R   t
   ValueErrorR   (   t   numR   t   i(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/Util/_number_new.pyR   C   s    

c         C   sÛ   t  |  t t f ƒ s, t  | t t f ƒ rW t d t |  ƒ j t | ƒ j f ƒ ‚ n  | d k r‘ | r‘ d } |  | | k rÁ t d ƒ ‚ qÁ n0 t |  | ƒ \ } } | d k rÁ t d ƒ ‚ n  |  | | k s× t ‚ | S(   s  Find and return an integer n such that p == n * d

    If no such integer exists, this function raises ValueError.

    Both operands must be integers.

    If the second operand is zero, this function will raise ZeroDivisionError
    unless allow_divzero is true (default: False).
    s&   unsupported operand type(s): %r and %ri    s   No solution could be found(	   R   R   R   R	   R
   R   R   R   R   (   t   pt   dt   allow_divzeroR   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/Util/_number_new.pyR   [   s    ,+N(	   t   __revision__t   __all__t   Crypto.Util.python_compatR    R   R   R   t   FalseR   (    (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/Util/_number_new.pyt   <module>   s   
				