
July 4th, 2007, 02:03 AM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 1
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?
|