Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7321ec43
Kaydet (Commit)
7321ec43
authored
Tem 26, 2001
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF bug #444510: int() should guarantee truncation.
It's guaranteed now, assuming the platform modf() works correctly.
üst
7cf92fa1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
libfuncs.tex
Doc/lib/libfuncs.tex
+1
-3
test_b1.py
Lib/test/test_b1.py
+13
-0
floatobject.c
Objects/floatobject.c
+13
-7
No files found.
Doc/lib/libfuncs.tex
Dosyayı görüntüle @
7321ec43
...
@@ -338,9 +338,7 @@ module from which it is called).
...
@@ -338,9 +338,7 @@ module from which it is called).
\exception
{
TypeError
}
is raised.
\exception
{
TypeError
}
is raised.
Otherwise, the argument may be a plain or
Otherwise, the argument may be a plain or
long integer or a floating point number. Conversion of floating
long integer or a floating point number. Conversion of floating
point numbers to integers is defined by the C semantics; normally
point numbers to integers truncates (towards zero).
the conversion truncates towards zero.
\footnote
{
This is ugly --- the
language definition should require truncation towards zero.
}
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
intern
}{
string
}
\begin{funcdesc}
{
intern
}{
string
}
...
...
Lib/test/test_b1.py
Dosyayı görüntüle @
7321ec43
...
@@ -366,6 +366,19 @@ except ValueError:
...
@@ -366,6 +366,19 @@ except ValueError:
pass
pass
else
:
else
:
raise
TestFailed
,
"int(
%
s)"
%
`s[1:]`
+
" should raise ValueError"
raise
TestFailed
,
"int(
%
s)"
%
`s[1:]`
+
" should raise ValueError"
try
:
int
(
1e100
)
except
OverflowError
:
pass
else
:
raise
TestFailed
(
"int(1e100) expected OverflowError"
)
try
:
int
(
-
1e100
)
except
OverflowError
:
pass
else
:
raise
TestFailed
(
"int(-1e100) expected OverflowError"
)
# SF bug 434186: 0x80000000/2 != 0x80000000>>1.
# SF bug 434186: 0x80000000/2 != 0x80000000>>1.
# Worked by accident in Windows release build, but failed in debug build.
# Worked by accident in Windows release build, but failed in debug build.
...
...
Objects/floatobject.c
Dosyayı görüntüle @
7321ec43
...
@@ -606,13 +606,19 @@ static PyObject *
...
@@ -606,13 +606,19 @@ static PyObject *
float_int
(
PyObject
*
v
)
float_int
(
PyObject
*
v
)
{
{
double
x
=
PyFloat_AsDouble
(
v
);
double
x
=
PyFloat_AsDouble
(
v
);
if
(
x
<
0
?
(
x
=
ceil
(
x
))
<
(
double
)
LONG_MIN
double
wholepart
;
/* integral portion of x, rounded toward 0 */
:
(
x
=
floor
(
x
))
>
(
double
)
LONG_MAX
)
{
long
aslong
;
/* (long)wholepart */
PyErr_SetString
(
PyExc_OverflowError
,
"float too large to convert"
);
(
void
)
modf
(
x
,
&
wholepart
);
return
NULL
;
/* doubles may have more bits than longs, or vice versa; and casting
}
to long may yield gibberish in either case. What really matters
return
PyInt_FromLong
((
long
)
x
);
is whether converting back to double again reproduces what we
started with. */
aslong
=
(
long
)
wholepart
;
if
((
double
)
aslong
==
wholepart
)
return
PyInt_FromLong
(
aslong
);
PyErr_SetString
(
PyExc_OverflowError
,
"float too large to convert"
);
return
NULL
;
}
}
static
PyObject
*
static
PyObject
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment