Grasshopper

algorithmic modeling for Rhino

Ok Guys....

this is something I really don't understand, and I've spent too much time trying to fix it....so I need your help again!

I attach the picture that will explain my little drama....

 

Why Equality is not working? Why at line 81 the result is "false" while it's clear that should be true!!! because if maths is not an opinion 0.738 is equal to 0.738!

 

please help me...I feel like an idiot!

 

thanks a lot!

 

Copia di A.jpg

Views: 1170

Replies to This Discussion

floating point maths is never as clear cut as you'd hope.

what is making these numbers not equal is the rounding error not displayed one can be 0.75 and the other 0.7499999999999999999999999999 or so. these are not equal.

if you use the approximately equal component instead of the directly equal this should help. either that or you round both numbers to a degree of accuracy you are comfortable with and then test for equality. either way its the same method really
Hi Giulio,

In addtion to Jonathon's comment, if you are sure that the z value you get from the point is 0.738 (not the rounding number of something else like 0.73799999), you should try convert both 0.738 to string and then get them connected to the Equality. I had a similar situation before, and still don't know why, but was able to make it work by converting numbers, integers into strings. Hope it will work.
Oh Jesus! My brain was melting yesterday night and I didn't even thing about the possibility of a rounded number!

Thank you so much guys! Now using the Similarity components it's working properly!

That was soooooo helpful! :D

PS (to Woo Jae, what do you mean with "convert to string"? Sounds like a good tip when things don't work and I can see the String component in GH, but I don't know what change it applies actually...)

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service