M
MS
Hi,
I haven't programmed in Java for a while and just wrote a program to calc
the odds of winning the British national lottery. BUT it is giving me the
wrong result !!
Here's the relevant bit:
public void DoCalc()
{
float winOdds = 49 * 48 * 47 * 46 * 45 * 44;
System.out.println(winOdds);
float anyOrder = 6 * 5 * 4 * 3 * 2;
System.out.println(anyOrder);
float res = winOdds / anyOrder;
System.out.println(res);
}
It outputs:
1.47841293E9
720.0
2053351.2
But the result should be:
10,068,347,520
720
13,983,816
Don't believe me? Paste the following into your calc program:
(49 * 48 * 47 * 46 * 45 * 44) / (6 * 5 * 4 * 3 * 2) =
Or let google do it:
http://www.google.co.uk/search?hl=e...+*+5+*+4+*+3+*+2)+=+&btnG=Google+Search&meta=
Am I going crazy? Why doesn't my Java program work?
Please help.
MS
I haven't programmed in Java for a while and just wrote a program to calc
the odds of winning the British national lottery. BUT it is giving me the
wrong result !!
Here's the relevant bit:
public void DoCalc()
{
float winOdds = 49 * 48 * 47 * 46 * 45 * 44;
System.out.println(winOdds);
float anyOrder = 6 * 5 * 4 * 3 * 2;
System.out.println(anyOrder);
float res = winOdds / anyOrder;
System.out.println(res);
}
It outputs:
1.47841293E9
720.0
2053351.2
But the result should be:
10,068,347,520
720
13,983,816
Don't believe me? Paste the following into your calc program:
(49 * 48 * 47 * 46 * 45 * 44) / (6 * 5 * 4 * 3 * 2) =
Or let google do it:
http://www.google.co.uk/search?hl=e...+*+5+*+4+*+3+*+2)+=+&btnG=Google+Search&meta=
Am I going crazy? Why doesn't my Java program work?
Please help.
MS