exercism / clojure

Exercism exercises in Clojure.

Home Page:https://exercism.org/tracks/clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Complex Numbers" Division Test Shows Fail but Answer is Correct

SSShupe opened this issue · comments

I passed all the tests on this exercise except the one relating to division. The test suite returned this:

Expected (= (c/div [1 2] [3 4]) [0.44 0.08]) but got (not (= [0.44 0.08] [0.44 0.08]))

My solution produces [0.44 0.08] which does equal [0.44 0.08], so I don't understand why I fail the test. Am I missing something? Thanks.

Hey :) Are you Nundrum on Slack/Exercism by chance? If not, this would be a great coincidence.

I'm inclined to think that the results are printing the same, but are in fact not equal because they are different kinds of numbers (i.e. floats vs. doubles). Could you post the code that is causing the tests to fail (just the c/div function should be adequate)? Thanks.

No not Nundrum (say that fast five times). I hadn't considered the floats vs. doubles issue. I recognized the division would produce ratios so I coerced the numerator and denominator to floats. I just changed the code to coerce to doubles instead, and now the code passes. Thanks for the suggestion.