Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

converting integers to BigDecimals

Thread view: 
BemusedbyQM - 12 Nov 2005 12:58 GMT
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?
Matt Humphrey - 12 Nov 2005 13:16 GMT
> how would you convert an ordinary 'int' integer into a java BigDecimal?
> i
[quoted text clipped - 3 lines]
> do
> this?

int j = ...;
BigDecimal bd = new BigDecimal (j);
Roedy Green - 12 Nov 2005 13:21 GMT
On Sat, 12 Nov 2005 13:01:07 GMT, "BemusedbyQM"
<groover892002@yahoo.co.uk> 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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.