I’m trying to achieve something pretty simple: I have an array of percentages and I want to make sure they all sum up to 1 (100%).
In the cell after the end of my array I enter the following formula:
SUM(my_array) + STYLE(IF(SUM(my_array) <> 1, "ERROR", "DEFAULT")).
Unfortunately my condition always evaluates to true, indeed using
SUM on an array of floats will never give you an exact result, this is how computers work. What’s the proper way to deal with that implementation detail? I have tried to define an epsilon constant with a very small value, and changed my predicate to
ABS(SUM(my_array) - 1) > epsilon, but the condition always evaluates to false.
What’s the proper way to do this?