mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Add float.imag, float.conjugate
This commit is contained in:
1 parent
bb878a3402
commit
4a598d03e2
2 files changed
+12
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user