Python is being weird. Am I missing something?

print crv.GetLength()
print crv.GetLength() == 2.0
print crv.GetLength() < 2.0
print crv.GetLength() > 2.0

Output:
image

I don’t see that here, I just get this output with a line of 2.0 mm:

2.0
True
False
False

edit: ah, not when rotated…

I remember this has to do with floating point rounding errors. Try this instead:

len =  round(crv.GetLength(),5)
print len
print len == 2.0
print len < 2.0
print len > 2.0

see also: 15. Floating Point Arithmetic: Issues and Limitations — Python 3.9.2 documentation

1 Like

Indeed floating point issues, from that floating point topic I love this:

Whenever you’re using floating point numbers (single or double precision, doesn’t matter), you can’t ever be sure a number you give to the computer can be properly represented by the computer.

3 Likes

Ok, that’s it. I’m uninstalling my computer…

4 Likes