frustrating arithmetic
- From: "Jonie" <kimfinale@xxxxxxxxx>
- Date: 27 Dec 2005 10:06:37 -0800
hi all,
i am looking forward to finding someone who could help me out. from
the following code,
i get 45 for the variable "numSusceptible" and 50 for "numNode". and
then i get 5 for "(numNodes - numSusceptible)". however, i get zero
when i calculate "(numNodes - numSusceptible) / numNodes". i don't
understand what is going on here. I would appreciate it if anyone
could help me understand. many thanks in advance.
private void getPrevalence() {
double prevalence = 0;
int numSusceptible = 0;
String string;
for (int i = 0; i < numNodes; i++) {
GayNode iNode = (GayNode) agentList.get(i);
string = iNode.getInfectStatus();
System.out.printf("status = %s ", string);
if (string.equals("s")) {
numSusceptible += 1;
}
}
prevalence = (numNodes - numSusceptible) / numNodes;
System.out.printf("\nSusceptibles = %d ", numSusceptible);
System.out.printf("numNodes = %d ", numNodes);
System.out.printf("prevalence =%.4f \n", prevalence);
//return prevalence;
}I
.
- Follow-Ups:
- Re: frustrating arithmetic
- From: Roedy Green
- Re: frustrating arithmetic
- From: Thomas Hawtin
- Re: frustrating arithmetic
- From: Rhino
- Re: frustrating arithmetic
- Prev by Date: Suduko solver demo
- Next by Date: Loop help
- Previous by thread: Suduko solver demo
- Next by thread: Re: frustrating arithmetic
- Index(es):