Jump to content

High value errors and how to deal with them?


Recommended Posts

I add and subtract the same exponentiated coordinate and up to 6 is fine, but 7 and above it squashes with cube.

BL0yJtC.png
TqLTGPw.png

code
 

vector pos = set(pow(10,7),0,0) ;
vector P = @P ;
P -= pos ;
P += pos ;
@P = P ;


Wondering if clamping is the only way to go... How do you deal with this sort of issue?

Cheers

Edited by probiner
Link to comment
Share on other sites

pretty sure rounding errors are happening with this dimensions. if you change the size of the cube it will also give strange results.

How I would deal with it is simply scaling everything down (but be aware that the same issues happen with very(!) small values aswell)

Link to comment
Share on other sites

  • 2 weeks later...

Cheers @3dome
I think I found a way to deal with this but I need to know the minimum acceptable value and the maximum acceptable value in VEX.
In Java there's `Float.MIN_VALUE` and `Float.MAX_VALUE`, or in C++ `FLT_MIN_EXP`  and `FLT_MAX_EXP`

Anyone one knows how to do this in VEX?

Cheers

Edited by probiner
Link to comment
Share on other sites

Hi,

I think this issue is not related to Float Min/Max Values, but it is related to rounding errors (which are not essentially errors) like Dominik already mentioned. If you have a float type, you have a minimum epsilon, which you can add to one, where you get a different result and for all smaller values the result is one. For the single float type [epsilon ~ 5e-7], so 1 + epsilon > 1 (but 1 + e = 1, for e < epsilon). Even if you add bigger numbers than epsilon, which are close to this machine constant epsilon, your results looks like adding natural multiples of this epsion to the result. You can check this effect in your example, if you add something 5*10^6 and perform a translation in x-direction before. I think the reason, why the cube is collapsing is, that the resolution for 5e-7 is even coarser than the distance between the box (min/max) - values.

Link to comment
Share on other sites

Yup my follow up question was exactly that. I want to know the shortest and the longest value possible in VEX without losing precision.
I would expect something like this:
FLT_MIN      = 1.175494e-38
FLT_MAX      = 3.402823e+38
And that between those two descriptions precision is maintained.

Now the question is, can I retrive these or I have to do some testing and ballpark it?

Cheers!

Edited by probiner
Link to comment
Share on other sites

Hi,

if you want to add numbers, the machine epsilon is what you are looking for. I think it was around 1e-7 for single float and 2e-16 for double float but VEX only supports single float AFAIK (I don't know, if you can get this constant directly but it is usually the same). So if you want to add a small to a big float you will get inaccurate result, if the factor between them is bigger than 1e-7. For example 1 + 1e-7, or 10 + 1e-6 or 1e7 + 1. I would prefer as limit the square root of the machine constant.

Numbers behind FLT_MIN and FLT_MAX are not even supported (underflow usually set as zero) and the precision is indepent from the size of the number, but it depends on the operations you'll perform.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...