This content has been marked as final.
Show 7 replies

1. Re: How to calculate percentage for two big integers?
843789 Jul 29, 2010 5:47 AM (in response to 843789)What have you done so far? What error's you getting?
James 
2. Re: How to calculate percentage for two big integers?
843789 Jul 29, 2010 5:51 AM (in response to 843789)10/4 : means 2.5
For BigInteger.divide I am getting 2.
I need fraction value also. 
3. Re: How to calculate percentage for two big integers?
843789 Jul 29, 2010 6:17 AM (in response to 843789)Integers give you whole numbers(2), not values (2.5)
Therefore you should look into doubles/floats etc. 
4. This Thread is now moved
darrylburke Jul 29, 2010 6:20 AM (in response to 843789)Note: This thread was originally posted in the [Java Programminghttp://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment. 
5. Re: How to calculate percentage for two big integers?
843789 Jul 29, 2010 6:22 AM (in response to 843789)Read the documentation of BigInteger. It can only represent whole numbers.
If you want fractions, you'll have to use BigDecimal. 
6. Re: How to calculate percentage for two big integers?
darrylburke Jul 29, 2010 6:22 AM (in response to 843789)javausers07 wrote:
As said, that's the expected behavior of any kind of integer division.
10/4 : means 2.5
For BigInteger.divide I am getting 2.
I need fraction value also.
Maybe you should be using BigDecimal ... or even, as suggested, doubles / floats.
db 
7. Re: How to calculate percentage for two big integers?
843789 Jul 29, 2010 7:05 AM (in response to darrylburke)Thank you, Itried new BigDecimal(BigInteger)...its working.