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
56cd67ad
Kaydet (Commit)
56cd67ad
authored
Ock 26, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Get rid of redundant type checks.
Define % operator similar to int%int.
üst
5ad58c6a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
53 deletions
+26
-53
floatobject.c
Objects/floatobject.c
+26
-53
No files found.
Objects/floatobject.c
Dosyayı görüntüle @
56cd67ad
...
...
@@ -139,86 +139,70 @@ float_compare(v, w)
static
object
*
float_add
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
float
object
*
w
;
{
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
return
newfloatobject
(
v
->
ob_fval
+
((
floatobject
*
)
w
)
->
ob_fval
);
return
newfloatobject
(
v
->
ob_fval
+
w
->
ob_fval
);
}
static
object
*
float_sub
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
float
object
*
w
;
{
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
return
newfloatobject
(
v
->
ob_fval
-
((
floatobject
*
)
w
)
->
ob_fval
);
return
newfloatobject
(
v
->
ob_fval
-
w
->
ob_fval
);
}
static
object
*
float_mul
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
float
object
*
w
;
{
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
return
newfloatobject
(
v
->
ob_fval
*
((
floatobject
*
)
w
)
->
ob_fval
);
return
newfloatobject
(
v
->
ob_fval
*
w
->
ob_fval
);
}
static
object
*
float_div
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
float
object
*
w
;
{
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
if
(((
floatobject
*
)
w
)
->
ob_fval
==
0
)
{
if
(
w
->
ob_fval
==
0
)
{
err_setstr
(
ZeroDivisionError
,
"float division"
);
return
NULL
;
}
return
newfloatobject
(
v
->
ob_fval
/
((
floatobject
*
)
w
)
->
ob_fval
);
return
newfloatobject
(
v
->
ob_fval
/
w
->
ob_fval
);
}
static
object
*
float_rem
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
float
object
*
w
;
{
double
wx
;
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
wx
=
((
floatobject
*
)
w
)
->
ob_fval
;
double
vx
,
wx
;
double
div
,
mod
;
wx
=
w
->
ob_fval
;
if
(
wx
==
0
.
0
)
{
err_setstr
(
ZeroDivisionError
,
"float
remainder
"
);
err_setstr
(
ZeroDivisionError
,
"float
modulo
"
);
return
NULL
;
}
return
newfloatobject
(
fmod
(
v
->
ob_fval
,
wx
));
vx
=
v
->
ob_fval
;
mod
=
fmod
(
vx
,
wx
);
div
=
(
vx
-
mod
)
/
wx
;
if
(
wx
*
mod
<
0
)
{
mod
+=
wx
;
div
-=
1
.
0
;
}
return
newfloatobject
(
mod
);
}
static
object
*
float_divmod
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
float
object
*
w
;
{
double
vx
,
wx
;
double
div
,
mod
;
object
*
t
;
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
wx
=
((
floatobject
*
)
w
)
->
ob_fval
;
wx
=
w
->
ob_fval
;
if
(
wx
==
0
.
0
)
{
err_setstr
(
ZeroDivisionError
,
"float divmod()"
);
return
NULL
;
...
...
@@ -245,15 +229,11 @@ float_divmod(v, w)
static
object
*
float_pow
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
float
object
*
w
;
{
double
iv
,
iw
,
ix
;
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
iv
=
v
->
ob_fval
;
iw
=
((
floatobject
*
)
w
)
->
ob_fval
;
iw
=
w
->
ob_fval
;
/* Sort out special cases here instead of relying on pow() */
if
(
iw
==
0
.
0
)
return
newfloatobject
(
1
.
0
);
/* x**0 is 1, even 0**0 */
...
...
@@ -347,10 +327,3 @@ typeobject Floattype = {
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
};
/*
XXX This is not enough. Need:
- automatic casts for mixed arithmetic (3.1 * 4)
- mixed comparisons (!)
- look at other uses of ints that could be extended to floats
*/
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