Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_strtod.cpython-311.opt-1.pyc |
�
�Ke9P � � � d dl Z d dlZd dlZd dlZd dlZ eedd� � dk r ej d� � � ej dej ej
z � � j Zdd
�Z
dZ G d� d
ej � � Zedk r ej � � dS dS )� N�float_repr_style� �shortzHcorrectly-rounded string->float conversions not available on this systemam # A numeric string consists of:
(?P<sign>[-+])? # an optional sign, followed by
(?=\d|\.\d) # a number with at least one digit
(?P<int>\d*) # having a (possibly empty) integer part
(?:\.(?P<frac>\d*))? # followed by an optional fractional part
(?:E(?P<exp>[-+]?\d+))? # and an optional exponent
\Z
�5 ����� c �F � t | � � }|�t d� � �|� d� � pd}t |� d� � |z � � }t |� d� � pd� � t |� � z
}|� d� � d k }|d
t |d� � z z d
t d| � � z }
} | s|rdnd
S | � � � |
� � � z
}||dk r| |z n| | z |
k z
}t ||� � |z
}| t | d� � z |
t |d� � z }
} t | |
� � \ }
}d|z |
k sd|z |
k r/|
dz r*|
dz
}
|
� � � |dz k r
|
dz }
|dz
}||
� � � z |k r|rdndS |
s|rdnd
S d|dz
dz z }d|dz
dz z
}|
|z ||z
}}
d� |rd nd|
d|z z |
d|z z ||d|z z � � S )z�Convert a finite decimal string to a hex string representing an
IEEE 754 binary64 float. Return 'inf' or '-inf' on overflow.
This function makes no use of floating-point arithmetic at any
stage.Nzinvalid numeric string�fracr �int�exp�0�sign�-�
r z -0x0.0p+0z0x0.0p+0� � �-inf�inf� � z{}0x{:x}.{:0{}x}p{:+d}� ) �
strtod_parser�
ValueError�groupr �len�max�
bit_length�divmod�format)�s�mant_dig�min_exp�max_exp�m�fraction�intpartr �negative�a�b�d�e�q�r�hexdigs�shifts �:/usr/local/apps/python3/lib/python3.11/test/test_strtod.py�strtodr1 sn � � �a���A��y��1�2�2�2��w�w�v���$�"�H��!�'�'�%�.�.�8�+�,�,�G�
�a�g�g�e�n�n�#��
$�
$�s�8�}�}�
4�C��w�w�v���#�%�H��2�s�3��{�{�?�"�B��A��t���$4�q�A�
� 7�&�6�{�{�J�6�
����������'�A��A��F�F�!�q�&�&��a�R��A� -�-�A��A�w���(�"�A�
��Q�B��
�
�?�A��Q����N�q�A��!�Q�<�<�D�A�q���s�Q�w�w�!�A�#��(�(�q�1�u�(� �Q����<�<�>�>�X�a�Z�'�'�
�!�G�A�
��F�A� �1�<�<�>�>��G�#�#�!�,�v�v�u�,�� 7�&�6�{�{�J�6� �8�A�:��/�!�G�
��!��Q���E���:�q�5�y�q�A�#�*�*�����R� �R��[�� �B��K��� �A�g�I�
�� � � r c � � e Zd Zd� Zd� Zd� Zd� Zd� Zd� Zd� Z e
j � e
j j
dz d d
�� � d� � � Zd
� Zd� ZdS )�StrtodTestsc � � t |� � }|� � � }n-# t $ r |d dk rdnd}Y nt $ r d}Y nw xY wt |� � }| � ||d� |||� � � � dS )z�Compare the result of Python's builtin correctly rounded
string->float conversion (using float) to a pure Python
correctly rounded string->float implementation. Fail if the
two methods give different results.r r r r zmemory errorzEIncorrectly rounded str->float conversion for {}: expected {}, got {}N)�float�hex�
OverflowError�MemoryErrorr1 �assertEqualr )�selfr �fs�got�expecteds r0 �check_strtodzStrtodTests.check_strtodW s� � � ��q���B� �&�&�(�(�C�C�� � 3� 3� 3��a�D�C�K�K�&�&�U�C�C�C�� !� !� !� �C�C�C� !���� �!�9�9������3�/�/5�v�a��3�/G�/G� I� I� I� I� Is �&