{"ScriptPreparationCode":"var value = -0.07\r\nvar step = 0.01\r\nvar min = -5\r\n// sorry we must use var and not let and const\r\nfunction validateStepWithAbs(value, step, min = 0) {\r\n if (value == null) return false\r\n\r\n var absValue = Math.abs(value)\r\n var absStep = Math.abs(step)\r\n var absMin = Math.abs(min)\r\n\r\n while (\r\n (absValue \u003E 0 \u0026\u0026 absValue \u003C 1) ||\r\n (absStep \u003E 0 \u0026\u0026 absStep \u003C 1) ||\r\n (absMin \u003E 0 \u0026\u0026 absMin \u003C 1)\r\n ) {\r\n value *= 10\r\n step *= 10\r\n min *= 10\r\n\r\n absValue = Math.abs(value)\r\n absStep = Math.abs(step)\r\n absMin = Math.abs(min)\r\n }\r\n\r\n return (value - min) % step === 0\r\n}\r\n\r\nfunction validateStepWithMultiply(value, step, min = 0) {\r\n if (value == null) return false\r\n\r\n while (\r\n (value !== 0 \u0026\u0026 value * value \u003C 1) ||\r\n (step !== 0 \u0026\u0026 step * step \u003C 1) ||\r\n (min !== 0 \u0026\u0026 min * min \u003C 1)\r\n ) {\r\n value *= 10\r\n step *= 10\r\n min *= 10\r\n }\r\n\r\n return (value - min) % step === 0\r\n}\r\n\r\nfunction validateStepWithSteps(value, step, min = 0) {\r\n if (value == null) return false\r\n var steps = (value - min) / step\r\n var remainder = steps % 1\r\n // Since the remainder could be close to either 0.99999999999999 or 0.00000000000001\r\n remainder = Math.round((remainder) * 1000000000) / 1000000000\r\n return remainder === 0 || remainder === 1\r\n}","TestCases":[{"Name":"Math.abs(x) ","Code":"validateStepWithAbs(value, step, min)","IsDeferred":false},{"Name":"compare x*x ","Code":"validateStepWithMultiply(value, step, min)","IsDeferred":false},{"Name":"use steps","Code":"validateStepWithSteps(value, step, min)","IsDeferred":false}]}