converting integers to BigDecimals


B

BemusedbyQM

how would you convert an ordinary 'int' integer into a java BigDecimal? i
have a java line that produces random java integers in the range 1 - 9 and i
want next to convert these integers into java BigDecimals. how would i do
this?
 
Ad

Advertisements

M

Matt Humphrey

BemusedbyQM said:
how would you convert an ordinary 'int' integer into a java BigDecimal?
i
have a java line that produces random java integers in the range 1 - 9 and
i
want next to convert these integers into java BigDecimals. how would i
do
this?

int j = ...;
BigDecimal bd = new BigDecimal (j);
 
Ad

Advertisements

R

Roedy Green

how would you convert an ordinary 'int' integer into a java BigDecimal? i
have a java line that produces random java integers in the range 1 - 9 and i
want next to convert these integers into java BigDecimals. how would i do
this?

Are you sure you don't want BigInteger?

If you did then new BigInteger( String ) will do it. You must convert
your int to String first. see
http://mindprod.com/applets/converter.html
for how.

If you want BigDecimal there is new BigDecimal ( int ). I am puzzled
why you had a problem with that one.
 

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

Similar Threads


Top