Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-07-2008, 08:45 PM
Member
 
Join Date: Nov 2007
Posts: 16
michcio has a little shameless behaviour in the past
get more decimals?!?! please help!
hello I wonder if there is a way to easy store a huge amount decimals. I have done a program that returns PI with many decimals that are right...But double can only store up to 14 decimals...how could I show my PI(System.out.println) ?? please help!!!

here is my short code

Code:
public static void main(String[] args) { double summa = 0; for(double i=0; i<100; i++) summa += Math.pow((-1),i)/(2*i+1) * (4/(Math.pow(5,(2*i+1)))-(1/Math.pow(239, (2*i+1)))); summa *= 4; System.out.println(summa); } }
it's a really short program that only add 100 of elemnts and then I got 14 deciomals right...but please help how do I do so I can see more then 14 decimals??????
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-07-2008, 11:06 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
BigD!
how about BigDecimal!!!
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-08-2008, 12:48 AM
Member
 
Join Date: Nov 2007
Posts: 16
michcio has a little shameless behaviour in the past
ah nice I didn't know there was a special class for this ...can BigDecimal have as many Decimals I want?...can you explain a bit how I should use it
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-08-2008, 08:31 AM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
Just like you working with double

But don't use +, - , *, / , instead use its owb methods:


See the link, This might be helpful for you:

http://java.sun.com/j2se/1.5.0/docs/...igDecimal.html
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-08-2008, 08:56 PM
Member
 
Join Date: Nov 2007
Posts: 16
michcio has a little shameless behaviour in the past
wow nice now I can finally write my PI ty very much
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-08-2008, 09:00 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
How about closing the thread as Solved
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-08-2008, 11:01 PM
Member
 
Join Date: Nov 2007
Posts: 16
michcio has a little shameless behaviour in the past
yeah how do I do that?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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

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



All times are GMT +3. The time now is 04:19 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org