My input is 0 but the equality component disagrees. Is this a bug or am I missing something?

# Equal to Zero

**Jack_Young**(Jack Young) #1

**Joseph_Oster**#2

Try `Smaller` instead, using an arbitrary, very small value like 0.0001 on the ‘B’ input. And use `Abs` (Absolute value) on the ‘A’ input to handle negative values; this can be done using the expression “abs(x)” directly on the ‘A’ input. Like this:

**davidsmavrov**(David S. Mavrov) #3

Yep, this will do the trick. Happened to me few days ago and this is exactly how I made my def working. But why does it happen in a first place?

**Michael_Pryor**(Michael Pryor) #4

Probably one of the most asked gh questions (and programming in general)

https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

**davidsmavrov**(David S. Mavrov) #6

Interesting read. I have noticed that the values weren’t exactly rounded.

**Piotr**#7

So when exactly Equality component can be used if every reading has some tolerance applied?

**Jack_Young**(Jack Young) #8

Many thanks for the help, that works perfectly. Michael, it might take a few weeks for me to get to the bottom of that!

**Joseph_Oster**#9

It’s not just zero, of course. The same technique applies to any value you want to match. If the difference is smaller than 0.0001, it’s a match!

**Michael_Pryor**(Michael Pryor) #10

Equality does exactly what it says. Tests if things are equal. Like very basically exactly equal. For instance if you have two numbers: 0.000000000000000001 and 0.000000000000000002. Grasshopper displays them to their set decimal. So it will display as 0.00 depending on your settings. But this does not mean the number is 0.00 - that is again just the decimal level you are displaying. Equality however is checking the real number and as you can see 0.000000000000000001 and 0.000000000000000002 are technically not the same.

You can change the decimal display in Grasshopper’s File>Preferences.

**DavidRutten**(David Rutten) #12

When you are comparing integers for example, no accuracy problems there. Or maybe if you first specifically round your floating point values to a small number of decimal places.

**Michael_Pryor**(Michael Pryor) #13

Maybe, but if comparing sliders it shouldn’t matter, sliders make the number they say they do. The issue is with values generated in other ways (area, lengths, ect.)

If I am not mistaken I recall reading somewhere that @DavidRutten is adding these tolerance tests to the future similarity component (which test currently only by percentage)

**Michael_Pryor**(Michael Pryor) #15

Well I’m not (Have it in Pufferfish ) but I am sure it will be a more than welcome addition to native GH - based on how many times this question is asked haha