+/- function in Java

Split from necro'd post

Page 1 of 1

1 Replies - 254 Views - Last Post: 20 September 2010 - 03:49 AM Rate Topic: -----

#1 Rumeo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-September 10

+/- function in Java

Posted 20 September 2010 - 01:22 AM

Please how do I represent the +/- function (i.e positive/negative) in a java code?
Is This A Good Question/Topic? 0
  • +

Replies To: +/- function in Java

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,961
  • Joined: 15-July 08

Re: +/- function in Java

Posted 20 September 2010 - 03:49 AM

*** Split from necro ***

You can't. You have to represent them as two different functions. Square root formula would be like this:
double[] roots = new int[2];
roots[0] = (-b + Math.sqrt(Math.pow(b,2)-4*a*a))/2.0*a;
roots[1] = (-b - Math.sqrt(Math.pow(b,2)-4*a*a))/2.0*a;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1