Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > converting integers to BigDecimals

Reply
Thread Tools

converting integers to BigDecimals

 
 
BemusedbyQM
Guest
Posts: n/a
 
      11-12-2005
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?


 
Reply With Quote
 
 
 
 
Matt Humphrey
Guest
Posts: n/a
 
      11-12-2005

"BemusedbyQM" <(E-Mail Removed)> wrote in message
news:nIldf.577$(E-Mail Removed)...
> 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);



 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      11-12-2005
On Sat, 12 Nov 2005 13:01:07 GMT, "BemusedbyQM"
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who 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?
>


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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
issue converting of std_logic_vectors into integers Andy Luotto VHDL 1 09-12-2008 04:00 PM
Formatting BigDecimals RedGrittyBrick Java 9 02-08-2008 11:35 AM
progrm for converting integers to roman numerals using files in clanguage kotlakirankumar@gmail.com C Programming 26 01-28-2008 09:55 PM
Converting integers to english representation Python 3 09-09-2004 10:08 PM
Converting from integers to output Krista Bailie Python 7 07-15-2004 09:04 AM



Advertisments