How do you divide 1.6 / 0.1

Started by
19 comments, last by GutenTag 8 years, 7 months ago


Conclusion: Your computer is haunted.

I'm assuming either he stopped at the wrong place in the debugging or copy/paste error.

Overall These all appear as expected.

Dividing by 0.1 is the same as multiplying by ten.

I'm assuming you mistyped or selected the x value after the first division because the before and after values didn't change.

The values are REALLY small, which is concerning.

The forces are:

-0.000026226

-0.00000000061118

0.0000256299

When you start working with bigger numbers, very often the CPU needs to bring them to the same scale.

We'll use addition because it is easy.

So let's say we're adding that acceleration to an existing acceleration:

10.1234 + -0.00000000061118

The result is a destructive operation. The first thing the CPU needs to do is bring them up to the same scale, and it has roughly six decimal digits of precision. So it rounds to (10.1234) + (-0.00000) = (10.1234)

Which probably leads to a result different from what he wanted, but correct (within precision requirements) for floating point math.

Advertisement

this is a new app its to test motion of units and to control the steering with a PID controller.

I think its some thing to do with the 5629997253417969e-005 the e-005;

because if I code

x = 1.6;

x = x / m;

x = 16.0.

my steering force is foobar.

last night I was thinking ghost in the machine, first comes paranoia then realization and only then maybe the fix. I call this the PRF affect.

Is it my force values.


5629997253417969e-005 the e-005;

It is just that the number is very small.

0.0000562999...

If you are talking meters, that is 56 micrometers. That's roughly the width of a human hair.

If you're talking meters per second, that is moving a human hair's width every second.

The one that had e-010, that's on the order of Angrstroms if you're looking at 1.0 being a meter. That is the size of a single atom.

Again, those numbers are really small.

Say What.

If you are talking meters, that is 56 micrometers. That's roughly the width of a human hair.

If you're talking meters per second, that is moving a human hair's width every second

That would be why my tank move so slow.

How do you apply a scale to the forces. the Book Programming game Ai by Example is Normalizing all the forces, which is leading to the small values.

nope just must of been late last night and I changed the DesiredVelocity D3DXVec3Length to D3DXVec3LengthSq and was getting tiny force.

and plus I got transfixed on why the steering force was the same after a divide Ahhhhh mutantph34r.png.

Oh now the fun of integrating the PID controller to steer the tank,, fun fun fun. Found it here

Yeah, I mentioned to pay attention to scale in each of the posts. I guess the fourth time is the charm. :-)

Orders of magnitude are important.

One or two orders of magnitude are usually normal in games.

Any time you see four or more orders of magnitude out of scale, it is so far distant that it doesn't even matter.

When you're working on meter scale, any power of ten (e0xx) more than +2 or -2 (or more) means something is likely broken.

Going bigger, e+2 and you're talking about the distance of sports arenas; still possible in games but less common. e+3 is kilometers where you're normally looking at different levels or zones and normally not used in games. e+4 and you're talking the scale of cities. e+6 and you're talking full planet diameter.

Going smaller, e-2 and you're talking centimeters which are about the limit downward. e-3 is millimeters, the scale of a fingernail width and usually too small for games. When you had e-5 you're on the scale of the width of a hair, e-10 you're on the scale of a single atom.

You'll get a much better experience in this forum if you post an actual program that we can compile and run ourselves to see the problem. Try to make the program "minimal", meaning you wouldn't be able to show the problem if it were any smaller. Very often you'll find the answer yourself in the process of writing this minimal program. And if you don't, you can post it here and we'll be able to help you much better.
I'm surprised that in 2015 C++ doesn't have a decimal data type for exactly these situations. IE. accurate floating-point/decimal math.

Beginner in Game Development?  Read here. And read here.

 

There have been several papers proposing decimal types for C++. Here's a relatively recent one. I know there were a few in 2004-2005, but they were poorly reviewed and didn't make it in.

I'm surprised that in 2015 C++ doesn't have a decimal data type for exactly these situations. IE. accurate floating-point/decimal math.

Considering that you're using VS10, you don't even have extensive access to C11. To be fair though, C++ is reaching that point in it's lifespan where it's becoming archaic.

I'm surprised that in 2015 C++ doesn't have a decimal data type for exactly these situations. IE. accurate floating-point/decimal math.


Considering that you're using VS10, you don't even have extensive access to C11. To be fair though, C++ is reaching that point in it's lifespan where it's becoming archaic.


I'm not sure where or how you're conjuring the idea that I'm using VS10. I use VS12 and 13.

Beginner in Game Development?  Read here. And read here.

 

This topic is closed to new replies.

Advertisement