python (3.12.0)
Αe9P 6 d dl Z d dlZd dlZd dlZd dlZ eedd dk7 r ej d ej dej ej z j ZddZ
dZ G d d
ej Zedk( r ej$ yy)
Nfloat_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
c t | }|t d |j d xs d}t |j d |z }t |j d xs d t | z
}|j d dk( }|d t |d
z z d t d
| z }
} | s|rdS dS | j
|
j
z
}||d
k\ r| |z n| | z |
k\ z
}t || |z
}| t | d
z |
t |d
z }
} t | |
\ }
}d
|z |
kD s
d
|z |
k( r*|
dz r%|
dz
}
|
j
|dz k( r
|
d
z }
|dz
}||
j
z |kD r|rdS dS |
s|rdS dS d|d
z
dz z }d|d
z
dz z
}|
|z ||z
}}
dj |rdnd|
d|z z |
d|z z ||d|z z S )zConvert 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.zinvalid numeric stringfracr intexp0sign-
r z -0x0.0p+0z0x0.0p+0 -infinf z{}0x{:x}.{:0{}x}p{:+d} )
strtod_parser
ValueErrorgroupr lenmax
bit_lengthdivmodformat)smant_digmin_expmax_expmfractionintpartr negativeabdeqrhexdigsshifts D/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_strtod.pystrtodr. s aAy122wwv$"H!''%.8+,G
aggen#
$s8}
4Cwwv#%H2s3{?"BAt$4qA
&{6J6
'AAF!q&aRA --AAw("A
QB
?AQNqA!Q<DAqsQw!A#(q1u Q<<>XaZ'
!GA
FA 1<<>G#!v,u,&{6J6 8A:/!G
!QE:q5yqA#**R R[ BK AgI
r
c e Zd Zd Zd Zd Zd Zd Zd Zd Z e
j j e
j j dz d d
d Zd
Zd Zy)StrtodTestsc t | }|j }t | }| j ||dj
||| y# t $ r |d dk( rdnd}Y Gt $ r d}Y Sw xY w)zCompare 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)floathex
OverflowErrorMemoryErrorr. assertEqualr )selfr fsgotexpecteds r- check_strtodzStrtodTests.check_strtodW s{ qB &&(C!93//5va3/G I 3aDCK&UC ! C !s A
A1$
A10A1c dD ]8 }dd|z z }dd|z z }|dz dk( r|dz
}t t D ] }t j ||d |}}|dz dk( r|dz |dz }}|dz dk( r||}}|dk rZd j || } | j | d j |d
dz z |dz
} | j | |dz }|dk rZ||}}|dk sd j || } | j | d j |d
dz z |dz
} | j | |dz }|dz }|dk r_ ; y )N)r r
l r>