diff options
author | Damien George <damien.p.george@gmail.com> | 2017-09-26 12:57:51 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-09-26 12:57:51 +1000 |
commit | bdc6e86e079dd8a82e9ead1d4041c2e17c882437 (patch) | |
tree | 07a5e178f400151ff6cd6d81752ebe0f3df0ae49 /tests/float/complex1.py | |
parent | 62849b7010abffb7b0a9c9875930efe7cb77519c (diff) | |
download | micropython-bdc6e86e079dd8a82e9ead1d4041c2e17c882437.tar.gz micropython-bdc6e86e079dd8a82e9ead1d4041c2e17c882437.zip |
py/objfloat: Support raising a negative number to a fractional power.
This returns a complex number, following CPython behaviour. For ports that
don't have complex numbers enabled this will raise a ValueError which gives
a fail-safe for scripts that were written assuming complex numbers exist.
Diffstat (limited to 'tests/float/complex1.py')
-rw-r--r-- | tests/float/complex1.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/float/complex1.py b/tests/float/complex1.py index 7f0b317b35..8544105453 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -53,6 +53,10 @@ print(type(hash(1j))) # float on lhs should delegate to complex print(1.2 + 3j) +# negative base and fractional power should create a complex +ans = (-1) ** 2.3; print("%.5g %.5g" % (ans.real, ans.imag)) +ans = (-1.2) ** -3.4; print("%.5g %.5g" % (ans.real, ans.imag)) + # check printing of inf/nan print(float('nan') * 1j) print(float('inf') * (1 + 1j)) |