ó
Xé?_c           @   sZ   d  Z  d d l m Z m Z m Z d d l m Z m Z d d „ Z	 d „  Z
 d g Z d S(   sD   
``python-future``: pure Python implementation of Python 3 round().
iÿÿÿÿ(   t   PYPYt   PY26t   bind_method(   t   Decimalt   ROUND_HALF_EVENc         C   s  t  } | d k r! t } d } n  t |  d ƒ r= |  j | ƒ S| d k  rX t d ƒ ‚ n  t d ƒ | } t r™ d t t	 |  ƒ ƒ k r™ t
 |  ƒ }  q™ n  t |  t ƒ r± |  } nB t sØ t j |  ƒ j | d t ƒ} n t |  ƒ j | d t ƒ} | rt | ƒ St
 | ƒ Sd S(   s©  
    See Python 3 documentation: uses Banker's Rounding.

    Delegates to the __round__ method if for some reason this exists.

    If not, rounds a number to a given precision in decimal digits (default
    0 digits). This returns an int when called with one argument,
    otherwise the same type as the number. ndigits may be negative.

    See the test_round method in future/tests/test_builtins.py for
    examples.
    i    t	   __round__s"   negative ndigits not supported yett   10t   numpyt   roundingN(   t   Falset   Nonet   Truet   hasattrR   t   NotImplementedErrorR   R    t   reprt   typet   floatt
   isinstanceR   t
   from_floatt   quantizeR   t   from_float_26t   int(   t   numbert   ndigitst
   return_intt   exponentt   d(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/future/builtins/newround.pyt   newround   s*    		
c   	      C   sæ   d d l  } d d l m } t |  t t f ƒ r; t |  ƒ S| j |  ƒ sY | j |  ƒ ri t t	 |  ƒ ƒ S| j
 d |  ƒ d k rŠ d } n d } t |  ƒ j ƒ  \ } } d „  } | | ƒ d } | | t | d | ƒ | ƒ } | S(	   sî  Converts a float to a decimal number, exactly.

    Note that Decimal.from_float(0.1) is not the same as Decimal('0.1').
    Since 0.1 is not exactly representable in binary floating point, the
    value is stored as the nearest representable value which is
    0x1.999999999999ap-4.  The exact equivalent of the value in decimal
    is 0.1000000000000000055511151231257827021181583404541015625.

    >>> Decimal.from_float(0.1)
    Decimal('0.1000000000000000055511151231257827021181583404541015625')
    >>> Decimal.from_float(float('nan'))
    Decimal('NaN')
    >>> Decimal.from_float(float('inf'))
    Decimal('Infinity')
    >>> Decimal.from_float(-float('inf'))
    Decimal('-Infinity')
    >>> Decimal.from_float(-0.0)
    Decimal('-0')

    iÿÿÿÿN(   t   _dec_from_tripleg      ð?i    i   c         S   s.   |  d k r& t  t t |  ƒ ƒ ƒ d Sd Sd  S(   Ni    i   (   t   lent   bint   abs(   R   (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/future/builtins/newround.pyt
   bit_length\   s    i   (   t   matht   decimalR   R   R   t   longR   t   isinft   isnanR   t   copysignR   t   as_integer_ratiot   str(	   t   ft   _mathR   t   signt   nR   R    t   kt   result(    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/future/builtins/newround.pyR   :   s    
		!R   N(   t   __doc__t   future.utilsR    R   R   R"   R   R   R
   R   R   t   __all__(    (    (    s   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/future/builtins/newround.pyt   <module>   s
   .	,