It occurs to me that you might try writing it to the precision storable by an unsigned double. That's the ceiling on the precision of your program, right? So that should make it come out zero? I may not understand the issues but it seems reasonable to me.

]]>But in the end, it seemed the inaccuaracies were small enough not to be detrimental to the program.

]]>How is it going now? Post code and problem if you can.

]]>First, I can't remember how C++ handles rounding when you assign a float to an integer; I think it truncates rather than rounds. If so, the algorithm (in psuedocode) looks something like this:

```
float number; //The number to be rounded
p = 5; //The precision to round to
float bumper = number * 10^p;
int chopper = (int) bumper;
int tester = (int) (bumper + 0.5);
if (tester > chopper) { float roundedNumber = tester * (1/10^p); }
else { float roundedNumber = chopper * (1/10^p); }
```

Again, my idea of C++'s rounding behaviour may be off, but I think you get the idea.

It's probably possible to do the same thing using bitwise wizardry, and such an approach may be simpler. But it would be a lot harder to implement and understand. Take your pick.

]]>What I need is a way to round a number to 4, or 5 decimal places.

]]>I'm writing a math program to calculate the location of a point (on an x,y plane) based on its x,y, z coordinates, the observers x,y,z coordinates, and the angle at which he's looking. Basicly I'm reinventing the 3d engine myself, trying to figure things out on my own. I've heard real 3d engines just use matrices but my system seems to work anyways.

Your object and origin suggestions are good, the only reason I didn't pic "origin" is because that usually means 0,0,0.

]]>