Notifications
Clear all

[Closed] Extended value

Hello all,
this should be a simple one but its got me massively confused. Im using a close_enough line on the 2 values. When i print them out the values are 0 and 3.28767e-005 i have to put the integer up to 17500000 or so before it recognizes them as close, at which point 30 is also “close”. I clearly don’t understand how the integer value works. I am looking to see if they’re within .01 or so of each other. The code I’m using is:

close_enough tempVert[3] pos1[3] 17500000

tempVert[3] and pos1[3] being the given values
about what would i have to set the integer to get .01 difference as being “close enough”
thanks

Edit: I gave up and just used absolute values and subtracted them and check if they were higher than a given value, if anyone has a solution to the close_enough I’d still really like to know how it works, seems like a pretty nifty function

2 Replies

Here you go, this is how it works:

fn close_enough_mxs f1 f2 rounds eps:1.19209e-7 =
	 f1 == f2 OR 2.0 * abs(f1 - f2)/(abs f1 + abs f2) < rounds * eps

Thanks very much, the fact that that eps is such a odd number would account for the craziness, i thought it would be something simple like for a value of 10 is up to 10 decimal places or something.