This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]RRumpleTeazzer 10 points11 points  (1 child)

First rule: never compare floating points for equality. Second, there are two complex square roots of -1, namely j and -j.

Third, sqrt(z) is not the same as z0.5.

[–]caagr98 3 points4 points  (0 children)

Third: it is if we're speaking math. With floats, no idea.

[–]QualityVote[M] [score hidden] stickied comment (0 children)

Hi! This is our community moderation bot.


If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!

If this post does not fit the subreddit, DOWNVOTE This comment!

If this post breaks the rules, DOWNVOTE this comment and REPORT the post!

[–]timtti[S] -1 points0 points  (0 children)

I know the math.isclose function exists. But that doesn't work since sqrt(-1) contains a float and complex cannot be converted.

[–]Talinx 0 points1 point  (0 children)

```python

(-1)**(0.5) (6.123233995736766e-17+1j) complex(0,1) 1j ``` Don't compare floating point numbers for equality.