Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.36 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.   root1 = real + imag
  8.   root2 = real - imag
  9. } else {
  10.   if (imag < 0) {
  11.     root1 = real + " - " + (-1 * imag) + "i"
  12.     root2 = real + " + " + (-1 * imag) + "i"
  13.   } else {
  14.     root1 = real + " + " + imag + "i"
  15.     root2 = real + " - " + (-1 * imag) + "i"
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement