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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top