????
Current Path : /proc/self/root/lib/python3.6/site-packages/future/builtins/__pycache__/ |
Current File : //proc/self/root/lib/python3.6/site-packages/future/builtins/__pycache__/newround.cpython-36.pyc |
3 �cv � @ sP d Z ddlmZ ddlmZmZmZ ddlmZm Z d dd�Z dd � ZdgZdS )zD ``python-future``: pure Python implementation of Python 3 round(). � )�division)�PYPY�PY26�bind_method)�Decimal�ROUND_HALF_EVENNc C s� d}|dkrd}d}t | d�r(| j|�S td�| }dtt| ��krNt| �} t| t�r^| }ntsntj| �}nt | �}|dk r�t || �| }n|j|td�}|r�t |�S t|�S dS ) a� 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. FNTr � __round__Z10Znumpy)Zrounding)�hasattrr r �repr�type�float� isinstancer Z from_float� from_float_26�newroundZquantizer �int)ZnumberZndigitsZ return_intZexponent�d�result� r �/usr/lib/python3.6/newround.pyr s( r c C s� ddl }ddlm} t| ttf�r*t| �S |j| �s>|j| �rJtt | ��S |j d| �dkr`d}nd}t| �j� \}}dd� }||�d }||t |d| �| �}|S ) a� 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') r N)�_dec_from_tripleg �?� c S s$ | dkrt tt| ���d S dS d S )Nr � )�len�bin�abs)r r r r � bit_length_ s z!from_float_26.<locals>.bit_length� )Zmath�decimalr r r Zlongr ZisinfZisnanr Zcopysignr �as_integer_ratio�str) �fZ_mathr Zsign�nr r �kr r r r r = s r )N) �__doc__Z __future__r Zfuture.utilsr r r r r r r r �__all__r r r r �<module> s 0,