I’ve got a problem that seems easy to solve, however I’m not sure on the syntax.
I need to have an if/else statement run, but I’m not sure on how to set the conditions correctly.
Bad code:
if (float_a = float_b or is within +-2 of it) {
do this
}
else {
do that
}
What’s the simplest way of accomplishing this?
You can use
Math.abs:This means “if the absolute difference between a and b is within 2…”.