Java Newbie can't do simple Math, operator error

Posted by elguapo-85 on Stack Overflow See other posts from Stack Overflow or by elguapo-85
Published on 2010-05-13T05:45:28Z Indexed on 2010/05/13 5:54 UTC
Read the original article Hit count: 231

Filed under:
|
|

Trying to do some really basic math here, but my lack of understanding of Java is causing some problems for me.


double[][] handProbability = new double[][] {{0,0,0},{0,0,0},{0,0,0}};
double[] handProbabilityTotal = new double[] {0,0,0};
double positivePot = 0;
double negativePot = 0;
int localAhead = 0;
int localTied = 1;
int localBehind = 2;
//do some stuff that adds values to handProbability and handProbabilityTotal

positivePot = (handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0));

negativePot = (handProbability[localAhead][localBehind] + (handProbability[localAhead][localTied] / 2.0) + (handProbability[localTied][localBehind] / 2.0) ) / (handProbabilityTotal[localAhead] + (handProbabilityTotal[localTied] / 2.0));

The last two lines are giving me problems (sorry for their lengthiness). Compiler Errors:


src/MyPokerClient/MyPokerClient.java:180: operator / cannot be applied to double[],double
            positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) );
                                                                                                                                                                                                                                             ^
src/MyPokerClient/MyPokerClient.java:180: operator + cannot be applied to double,
            positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) );
                                                                                                                                                                                                 ^
src/MyPokerClient/MyPokerClient.java:180: operator / cannot be applied to double,
            positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) );

Not really sure what the problem is. You shouldn't need anything special for basic math, right?

© Stack Overflow or respective owner

Related posts about java

Related posts about compiler-errors