Grasshopper

algorithmic modeling for Rhino

Hallo everybody!

Does anybody has an idea why the above function function doesn't work properly?

(True state is that x and y are equal)

Thanks!

Views: 2015

Replies to This Discussion

I'm not 100% sure, but I think the two operate with slightly different tolerances. When I compare 4.0000000000001 and 4, the equality component says they are equal, and the function component says they are not. What values exactly are you giving?

If this is presenting a problem, you might take a look at the "near equality" operator in the function component - As I understand it it only compares up to 10 decimal places. 

12 decimal places in fact, so yeah, this is probably a rounding artefact. 

NEVER use equality on floating point values that come from different sources, always compute the difference and compare it to a tolerance you're happy with:

Abs(x-y) < 1e-8

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks!

It seems to work with a tolerance up to  1e-14

However,  I don't see any difference in the input values. They seem to be the same (and by geometrical definition must be the same, because they express the area of the same exactly boundary) and they go until 6 digits

The panel only shows is a string representation to 6 dp of that number.

And where can I see the whole number?

Is it a settings matter?

there are some numbers that cannot be shown in that sense think root 2 and PI they go on on

you might be able to force the issue with a format function in an fx component.

format("{0:0.00000000000000}",x)

Format("{0:R}", x)

The "R" stands for "Roundtrip", meaning the string representation of the number is guaranteed to be lossless. You may end up with a thoroughly unreadable bit of text though.

Format("{0:0.0###############}", x)

This formatting mask forces a single decimal, and allows for 15 more if they are significant. You can combine any number of "0"s and then "#"s to suit your needs.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks!

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