Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.37 KB | None | 0 0
  1. val real = -1 * b / (2 * a)
  2. val imag = d / (2 * a)
  3.  
  4. val root1
  5. val root2
  6. if (underR >= 0)
  7. {
  8.   root1 = real + imag
  9.   root2 = real - imag
  10. }
  11. else
  12. {
  13.   if (imag < 0)
  14. {
  15.     root1 = real + " - " + (-1 * imag) + "i"
  16.     root2 = real + " + " + (-1 * imag) + "i"
  17.   }
  18. else
  19. {
  20.     root1 = real + " + " + imag + "i"
  21.     root2 = real + " - " + (-1 * imag) + "i"
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement