Grasshopper

algorithmic modeling for Rhino

Hello David,

Something unexpected here.

I get those lines (a parking building from a series of a larger algorithm that includes some Split surface also). In any case, I end up with those CRVs and want to cull out those with length equal to 240. For some reason some of them are not culled. Although I measure them with even the highest possible tolerance in Rhino and they are indeed 240. Also GH sees them as 240.

Appreciate your time to give some advice.

Thanks,

Dimitris

Views: 435

Attachments:

Replies to This Discussion

You can not compare floating point numbers. Never ever. Only integer numbers can be equated in this way. When dealing with floating point values you have to either compare the absolute difference to a tolerance value, or you can use the Similarity component.

Comparing floating point numbers using equality will only work if you're comparing numbers that have been assigned and subsequently have never encountered any mathematical operation. See this FAQ postfor more details.

If I display your numbers without any rounding, you can see that only some of them are really 240.0, others have slightly different values:

Incidentally, the formatting pattern in the F input of [Format] is {0:R}

The 'R' stands for round-trip, meaning that when the text representation is parsed back into numbers you'll get the same number out. In other words, there's no rounding going on.

Very educational!

Thank you very much!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service