Add float.imag, float.conjugate

This commit is contained in:
Jeong YunWon committed 2019-05-01 21:31:02 +09:00
1 parent bb878a3402
commit 4a598d03e2
2 files changed
+12

No files matched your search

+2
View File
@@ -140,6 +140,8 @@ assert_raises(OverflowError, lambda: 1.2 ** (10 ** 1000))
assert 3 ** 2.0 == 9.0
assert (1.7).real == 1.7
assert (1.7).imag == 0.0
assert (1.7).conjugate() == 1.7
assert (1.3).is_integer() == False
assert (1.0).is_integer() == True
+10
View File
@@ -364,6 +364,16 @@ impl PyFloat {
zelf
}
#[pyproperty(name = "imag")]
fn imag(&self, _vm: &VirtualMachine) -> f64 {
0.0f64
}
#[pymethod(name = "conjugate")]
fn conjugate(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyFloatRef {
zelf
}
#[pymethod(name = "is_integer")]
fn is_integer(&self, _vm: &VirtualMachine) -> bool {
let v = self.value;