mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 04:30:24 +01:00
py/parsenum: Fix parsing of complex "j" and also "nanj", "infj".
Prior to this commit, complex("j") would return 0j, and complex("nanj")
would return nan+0j. This commit makes sure "j" is tested for after
parsing the number (nan, inf or a decimal), and also supports the case of
"j" on its own.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -4,14 +4,19 @@
|
||||
print(complex(1))
|
||||
print(complex(1.2))
|
||||
print(complex(1.2j))
|
||||
print(complex("j"))
|
||||
print(complex("J"))
|
||||
print(complex("1"))
|
||||
print(complex("1.2"))
|
||||
print(complex("1.2j"))
|
||||
print(complex("1+j"))
|
||||
print(complex("1+2j"))
|
||||
print(complex("-1-2j"))
|
||||
print(complex("+1-2j"))
|
||||
print(complex(" -1-2j "))
|
||||
print(complex(" +1-2j "))
|
||||
print(complex("nanj"))
|
||||
print(complex("nan-infj"))
|
||||
print(complex(1, 2))
|
||||
print(complex(1j, 2j))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user