# Floating max number

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

## Recommended Posts

Hi. Im thinking of comparing a pixel = meter. It's a car game. So if it is moving like 100 m/s, it will move 100 pixels per second. I'd like to know if it is too exagerated so the floating variables that hold the position values, will get to it max value too quickly.. In first of all, what is the range of a floating variable? I searched and found this: 3.4e +/- 38 (7 digits) what this means? 3.4 x10^38 ? It hols more then an integer? So, what is the best I can do in this situation? Should I change the comparison and put something like 1meter = 0.1 pixel ? thanks

##### Share on other sites
Yep, it's about 3.402823466e+38, which is approx. 3.4x10^38 as you said.

In your case, I really doubt that you need higher precision unless you're going to use gigantic worlds.

A light year is approximately 9.46x10^15 meters. So a floating point number's maximum value interpreted as meters would be about ~3.6x10^22 light years. The observable universe is only about ~100 billion light years across.

However, this is the wrong way to look at it. At large numbers, floating point numbers lose more and more accuracy. It just depends on how much accuracy you are willing to sacrifice.

This table from an article on Ageia's website explains it quite nicely:

Distance from origin (world units)      Smallest detail size (world units)1                                       0.000000119209289510                                      0.000000953674316100                                     0.000007629394531,000                                   0.000061035156210,000                                  0.0009765625100,000                                 0.00781251,000,000                               0.062510,000,000                              1.00100,000,000                             8.001,000,000,000                           64.010,000,000,000                          1024

Going by that table, if you measure everything in meters, once your car gets about 10,000 kilometers from the world origin you'll have a minimum of about 1 pixel inaccuracy.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633701
• Total Posts
3013444
×