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
d4256302
Kaydet (Commit)
d4256302
authored
Ara 06, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Small set of updates (with Jeffrey's OK).
üst
280ca080
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
11 deletions
+33
-11
numbers.py
Lib/numbers.py
+33
-11
No files found.
Lib/numbers.py
Dosyayı görüntüle @
d4256302
...
...
@@ -43,6 +43,7 @@ class Inexact(Number):
Inexact
.
register
(
complex
)
Inexact
.
register
(
float
)
# Inexact.register(decimal.Decimal)
class
Complex
(
Number
):
...
...
@@ -97,7 +98,7 @@ class Complex(Number):
def
__pos__
(
self
):
"""+self"""
r
eturn
self
r
aise
NotImplementedError
def
__sub__
(
self
,
other
):
"""self - other"""
...
...
@@ -119,7 +120,7 @@ class Complex(Number):
@abstractmethod
def
__div__
(
self
,
other
):
"""self / other"""
"""self / other
; should promote to float or complex when necessary.
"""
raise
NotImplementedError
@abstractmethod
...
...
@@ -129,7 +130,7 @@ class Complex(Number):
@abstractmethod
def
__pow__
(
self
,
exponent
):
"""
Like division, self**exponent should promote to
complex when necessary."""
"""
self**exponent; should promote to float or
complex when necessary."""
raise
NotImplementedError
@abstractmethod
...
...
@@ -152,9 +153,7 @@ class Complex(Number):
"""self == other"""
raise
NotImplementedError
def
__ne__
(
self
,
other
):
"""self != other"""
return
not
(
self
==
other
)
# __ne__ is inherited from object and negates whatever __eq__ does.
Complex
.
register
(
complex
)
...
...
@@ -180,8 +179,30 @@ class Real(Complex):
"""trunc(self): Truncates self to an Integral.
Returns an Integral i such that:
* i>0 iff self>0
* abs(i) <= abs(self).
* i>0 iff self>0;
* abs(i) <= abs(self);
* for any Integral j satisfying the first two conditions,
abs(i) >= abs(j) [i.e. i has "maximal" abs among those].
i.e. "truncate towards 0".
"""
raise
NotImplementedError
@abstractmethod
def
__floor__
(
self
):
"""Finds the greatest Integral <= self."""
raise
NotImplementedError
@abstractmethod
def
__ceil__
(
self
):
"""Finds the least Integral >= self."""
raise
NotImplementedError
@abstractmethod
def
__round__
(
self
,
ndigits
:
"Integral"
=
None
):
"""Rounds self to ndigits decimal places, defaulting to 0.
If ndigits is omitted or None, returns an Integral, otherwise
returns a Real. Rounds half toward even.
"""
raise
NotImplementedError
...
...
@@ -241,7 +262,7 @@ class Real(Complex):
@property
def
real
(
self
):
"""Real numbers are their real component."""
return
self
return
+
self
@property
def
imag
(
self
):
...
...
@@ -250,9 +271,10 @@ class Real(Complex):
def
conjugate
(
self
):
"""Conjugate is a no-op for Reals."""
return
self
return
+
self
Real
.
register
(
float
)
# Real.register(decimal.Decimal)
class
Rational
(
Real
,
Exact
):
...
...
@@ -358,7 +380,7 @@ class Integral(Rational):
@property
def
numerator
(
self
):
"""Integers are their own numerators."""
return
self
return
+
self
@property
def
denominator
(
self
):
...
...
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