1
$\begingroup$

Such simple task goes wrong somehow (result of comparing inside Expression is far from expected):

enter image description here

What did I overlook here?

$\endgroup$
1
$\begingroup$

Floats in general have a limited precision and most real numbers can not be fully represented using a float. So when you set the input float node to 0.1, it is actually represented internally as 0.100000001490116119384765625. See this answer for more information. Python's representation of 0.1 is different from blender's representation, python's is more accurate 0.1000000000000000055511151231257827021181583404541015625. Hence the result you see in your setup.

In general, don't try to compare floats as this may yield some unexpected results. You can use something like isclose() function to compare floats, this function is the standard math module.

$\endgroup$
  • $\begingroup$ Well, a man can easily end up in asulym trying to assume that not every 0.1 is equal to 0.1. Thank you, Omar! $\endgroup$ – Serge L Feb 25 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.