Is it a bug?

According to _List command Rhino says that the line end point is:
end = (3.003319090732994e-16, -4.104148255938665e-14, -1)

But, _What tells that it is:
end = (0.00,-0.00,-1.00)

Well, _What is right however in Python script rs.CurveEndPoint() returns the first result.

I have generated this line from Python by script:

vect = rs.SurfaceNormal(profileStart,[0,0])
vect = rs.VectorUnitize(vect)
pt_ = rs.AddPoint(vect)
vect_line = rs.AddLine([0,0,0],pt)

Bug.3dm (21.3 KB)

There is no bug.

The first number is 0.0000000000000003003319090732994 (e-16 means move decimal separator 16 places to the left). -4.10e-14 likewise is -0.00000000000004104148255938665. Both are essentially 0.00 and -0.00 when rounded to the tolerance.

There have been many topics on our forum on this funky part of computers and representing floating point numbers and the arithmetics with it. Whenever working with floating point numbers: don’t ever rely on comparing floating point numbers directly, especially not when they are the result of computation.

For fun:

  • run _EditPythonScript
  • create an empty script
  • paste the line: print((0.1 + 0.1 + 0.1) == 0.3)
  • run the script
  • be amazed / confused

For further education: Floating-point arithmetic - Wikipedia

3 Likes