Don't require a decimal for formulas to calculate non-whole numbers

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Locked
vertigo
Posts: 147
Joined: 28 Oct 2018 00:28

Don't require a decimal for formulas to calculate non-whole numbers

Post by vertigo » 30 Oct 2019 17:48

I spent about an hour the other day trying to figure out why a script wasn't working properly, since it was resulting in zero instead of the number it should have been coming out to. After checking and rechecking and tweaking it to see what the problem was, I found this thread which made me realize Automagic basically automatically performs the floor function on every calculation unless one of the numbers includes a decimal. This doesn't make sense, as a) that's not standard practice and I've never seen anything handle calculations that way, and b) there's a floor function, and that's what it's for, so if the user wants it treated that way, the function should be used. It doesn't make sense to have the function when it's automatically done regardless (I realize there are probably cases where it would still be needed, but I digress). In fact, I was using the floor function for the entire calculation (i.e. floor(((a+b)-c)*d)) and so part of my troubleshooting was trying to figure out if it was incorrectly being applied to the wrong thing, whether due to incorrect parentheses placement or a bug, or the entire thing, due to a bug. The implementation of automatically applying a floor function when a decimal isn't included is unintuitive, and the linked thread shows I'm not the only one to be confused and led astray by it, and I think it should be changed.

Locked