Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 4th, 2007, 02:03 AM
Carvin Carvin is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 1 Carvin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 20 sec
Reputation Power: 0
Noob question - large variables?

I'm semi-new to java and have been trying to make a program which simulates orbits and other gravitational forces between planets, moons, spaceships, etc. in two dimensions.

As an example of the kind of numbers im trying to deal with, the mass of the earth is 5.9736×10^24 kg and the mass of the moon is 7.3477×10^22.

I'm a bit confused as to how java handles large numbers.. it seems I am unable to make any variables with values higher than 2 billion (2x10^9) without a compiler error. I'm using JCreator, and when I try to compile my applet with numbers higher than this it simply says: "integer number too large"

I have tried it with ints, doubles, and longs to store my data, but they all throw the same error. Am i missing something here? it was my understanding that at least ints and longs could contain values much greater then this.. How would I go about storing large numbers without losing precision?

Reply With Quote
  #2  
Old July 14th, 2007, 07:09 AM
The Guardian The Guardian is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 3 The Guardian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 33 sec
Reputation Power: 0
Help

Gah, posted when I didn't realize you had already tried doubles and longs.
Sorry. I can't help you with that.

Reply With Quote
  #3  
Old July 26th, 2007, 07:06 PM
xreddawg909x xreddawg909x is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 91 xreddawg909x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 27 m 20 sec
Reputation Power: 4
why not try an if statement replaceing the 0's with ^

when the number exceeds 2 billion ?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Noob question - large variables?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT