On Sat, 2008-08-30 at 15:18 +0200, Vincent Verhoeven wrote:
> 2008/8/30 Krzysztof Sobolewski <[EMAIL PROTECTED]>:
> > I guess I'll have to use BigIntegers to calculate distances. I wonder how 
> > much it'll destroy the performace... :) [Or does someone know an 
> > overflow-resistant way to calculate a distance?]

A real simple solution would be to divide all your distances by a
constant which is something like 1/1e6 of the universe size. I doubt you
need more accuracy then that.

Some ruleset might only use really small numbers too (IE around the 10s
or 100s), so using "absolute" sizes is definitely not the best choice.

> Let's see... Correct me if I'm wrong. Some outside planet locations:
> -2399968326000, 1119431722500, 0
> 7234116540000, 889698663000, 0
> 6608869260000, -3654547470000, 0
> 
> Thus 9 634 084 866 000 x 4 773 979 192 500.

9634084866000 / 9634084 = 1000000
4773979192500 / 9634084 =  495530

Which are much more manageable.

> For RFTS, I have
> 
> 210000000, 2992500000, 0
> 3612000000, 157500000, 0
> 
> which yields 3 402 000 000 x 2 835 000 000, or essentially a factor
> 3000x2000 smaller. Hmm. :)

3402000000 / 3402 = 1000000
2835000000 / 3402 =  833333

All these numbers definitely fit inside long ints.

Tim 

_______________________________________________
tp-devel mailing list
[email protected]
http://www.thousandparsec.net/tp/mailman.php/listinfo/tp-devel

Reply via email to