Small Number Problem

Posted by Shork on Dec. 7, 2006, 4:12 p.m.

I found a problem with Game Maker. It cannot handle small numbers. I was doing more work on my Satelite Orbit Mimicker program when I discovered this. I was using a new code for the gravity calculations, this was close to the exact stuff:

gravity_direction = point_direction(x,y,Planet.x,Planet.y)
gravity = (6.67*10^-11)/(point_distance(x,y,Planet.x,Planet.y)^2

The gravity equation I used here is as close as I can get to the real Universal Gravitation Law, even with the real Gravitational constant 6.67*10^-11. However, when I ran this, the object would approach the planet with gravity of 2, (I used a draw_text(x,y,gravity)), then as it got close, gravity would switch to -3, and the object would fly away from the planet, only to switch back to 2 and come back, before going back to -3. Also, the gravity was never continous, it was only 2 and -3, never anything in between. I was able to solve the negative gravity problem by replacing the 6.67*10^-11 with .5, which is too big to be really accurate, but it seems to work better. I can't figure out what exactly caused the negative gravity, becuase none of the terms in the equation I used could ever be negative. Do any of you better programmers know what might be going on? Or have I actually found a problem with the way GM handles tiny numbers?

Comments

Cesar 18 years ago

When I gave it a shot at astrophysics, I put a formula for gravity based on object size, and I made the object have a set speed, at a very, VERY small angle, so after 100+ turns, it moved about 0.0001 pixels away from the "sun"

And I doubt any programming language can handle super-small numbers or super-large numbers

Shork 18 years ago

My physics professor did his graduate work on the most powerful supercomputer in the nation at the time. He was modeling 1 billion atoms of hydrogen in plasma form, and it took 2 days to do the calculations. Since most substances are measured in moles, and one mole is 6.022*10^23 atoms, doing a real calculation would take about 5 times the age of the universe.

Cesar 18 years ago

holy crap, but then again, it's a supercomputer with a superlanguage :P (yes, I just made up superlanguage)

Nailog 18 years ago

^ is not an exponent operator in GM. It is a bitwise operator.

Use the power() function instead.

Shork 18 years ago

HOLY HELL THAT WAS MY PROBLEM!!!

Why can't it just use real math?