Computer is storing weird numbers

If I set a vertex’s location to 1.5, it says its location is 1.5, but later when I look in the properties panel it says it is at a weird location lie 1.499982483274. This is really annoying, and after a while, it shifts the vertex’s location so my super nice model that was neat suddenly has crazy numbers. Does anyone know why this is happening?

Is it something specifically wrong with MY computer or is it something wrong with the software? Thanks, sorry for the really late reply.

Both. There are limitations to EVERY computer. Some numbers such as 0.1, represented as binary repeat forever. Computer hardware can only store so many of these bits, 16, 32, 64 etc… Given a location of 1.5, if no operations are done on the vertex should remain at 1.5. Most operations, rotations for example, are calculated using a method of adding a series of numbers. When you repeatedly add numbers that have inaccurate representations errors form.

So if you operate on the vertex you will get these errors. You say this is not to your liking, I agree, but is it acceptable. If not, software can be written to calculate at a greater precision than the hardware it runs on, so in theory you could build Blender so that 1.5 would stay 1.5 no matter what operation you did on the vertex.

The other solution would be to plan your mesh on paper and then enter your points programmatically.

So terry, you are saying that my computer knows that it can not represent 1.5 correctly, so it goes as close as possible, but still tells me it’s 1.5, but when I do a rotation operation (by the way, can you explain to me how that works?) it doesn’t see it as 1.5 even when a perfect computer should?

A computer cannot represent all numbers perfectly without error. This is why accounting software uses all integers under the hood.

A rotation is made from sine functions and cosine functions. These functions, using calculus, can be represented by a sequence of additions. Unfortunately, for a perfect calculation the sequence has to be infinite. So again, we do the best we can and calculate to some acceptable error.

For your software you can have one precision for input/output and another for your calculations. So you could input 1.5 then have your calculations done at a higher precision so that 1.5 is always output as 1.5. For an example look at how HDR is calculated.

In simple terms, your computer is doing this:

Start with a value, say 1.5, then add one ninth (for convenience lets say your computer rounds the actual value 0.1111111… to 0.1111) nine (9) times and then subtract one (1). You should get 1.5 but due to the rounding your computer did you will give a result of 1.4999.

While this example may be exagerated (your computer is more precise than that), it is the same idea.

You may start with a very nice and precise number like 1.5 but a series of calculations, particularly where rotations about a point are involved are involved (recall pi can be calculated to millions of decimal places but your PC is incapable of computations at this level of precision and like Terry says, sine and cosine functions will be somewhat lossy), may result in a value that is very close to that which would be expected in a perfect world.

Hope this is helpful.

Cheers