converting BigDecimal to BigInteger

J

Jeremy Watts

Hi,

How would you convert a 'BigDecimal' number to a 'BigInteger' ? I cant seem
to be able to do this.

More specifically, lets say I had the BigDecimal 5.0000, and wanted to
convert this to 5 , and then have Java treat that as '5' in BigInteger
form , then how would I do this?

Thanks
 
K

karoshi

Jeremy said:
How would you convert a 'BigDecimal' number to a 'BigInteger' ?

BigDecimal myBigDecimal = new BigDecimal(5.0d);
BigInteger myBigInteger = myBigDecimal.toBigInteger();
 
R

Roedy Green

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top