#### Archived

This topic is now archived and is closed to further replies.

# [Hello!] Floating point accuracy

This topic is 6932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all! I''m Nanoprobe. You may know me from such message boards as the Independence War fourum... yada yada yada... Now that I have that bit over with, I have this question. I am creating a 3d engine to play with (possibly to make a game on), and I want it to be mainly a space engine. I have this idea that if I use 3 long integers and 3 doubles to define a co-ordinate, the floating point numbers can refer to a ''sector'' of space defined by the longs. That''s the best way I can explain it. Anyway, the way I have it worked out is that if 1 using a long integer equals 1 million kilometres as a double, my gameworld could be made up of a cube of space over 400 light years from one side to another, accurate down to the centimetre! Is this right, or have I gone wrong somewhere? Also, if I end up making a space game with this engine, would accuacy to 1cm do? Or should I go to, say, 1 long unit = 100,000 double units?
 - Nanoprobe E-Mail Colliderring.com ICQ# 48856642

##### Share on other sites
Hi Nanoprobe!

You calculations are correct.
A double has got 11 exponent bits, 52 accuracy bits.
10000000 km = 100000000000000 µm
and 2^52 = 4503599627370496 so this would be accurate enough!

GA

##### Share on other sites
400 cubic light years? Now, what are you gonna put in it (I want a solar system at grid co-ordinate [4][11][15] please )?

I''m talking gibberish now so i''ll stop

MENTAL

##### Share on other sites
Just as I thought, thanks guys!

I did end up to coding to 200,000 wide sectors, and added a reference point to the reference point.

I now roughly gave myself enough space to make the entire galactic cluster.

I think I might hang around on this board for a while too, and I''ll tell you about my engine as I go along. I think I like this board better than the Independence War one because you get icons and it saves my HTML sig.

 - Nanoprobe E-Mail Colliderring.com ICQ# 48856642

##### Share on other sites
There''s only one problem: You need more than 400 years to travel 400 lightyears! *gg*

GA

##### Share on other sites
Try FTL propulsion, it makes those long distances seem so much shorter.

 - Nanoprobe E-Mail Colliderring.com ICQ# 48856642

##### Share on other sites
Okay, if you''re near light speed, the distance seems much shorter, but not for those who stay on earth - they''ll all be dead when you''re back.....

GA

##### Share on other sites
Don''t get technical with me - remember, I come from the Independence War forum. :D

 - Nanoprobe E-Mail Colliderring.com ICQ# 48856642

• 10
• 13
• 52
• 11
• 15