Creating a range of values for self correcting problems

There’s a few ways:
correct = this.numericValue >= 0.4 and this.numericValue <= 0.41

or within (in this example) 0.01 of 0.41:
correct = numericValue("\abs(0.41-${this.numericValue})") <= 0.01
(Edit: I like the above because you can see the value intended as well as the tolerance desired. You could also have a variable instead of 0.41, so you could reuse the code and only have to change said variable. As opposed to the one below, because you may need to calculate the 0.41 somehow which would then require a similar rounding format making it a bit clunky looking.)

If you wanted correct rounding to 2 decimal places:
correct = numericValue("\round(${this.numericValue},2)") = 0.41

1 Like