Why is .* used in Java? For example
double probability = 1.*count/numdata;
gives the same output as:
double probability = count/numdata;
Why is .* used in Java? For example
double probability = 1.*count/numdata;
gives the same output as:
double probability = count/numdata;
If count
and numdata
are integral: int
or long
the result again will be integral (integer division), so the fractions gets lost; truncated, not even rounded. As a probability is between 0.0 and 1.0, and so numdata >= count, you'll get only 0 or 1.
Simplest would be to make the division floating point:
double probability = ((double)count) / numdata;
or (more obfuscating though!)
double probability = count;
probability /= numdata;