Browse Source

add is_within

master
Jonathan Cobb 3 years ago
parent
commit
7ff35206d5
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      src/main/resources/org/cobbzilla/util/javascript/standard_js_lib.js

+ 5
- 0
src/main/resources/org/cobbzilla/util/javascript/standard_js_lib.js View File

@@ -174,3 +174,8 @@ function pct_diff (x, y) {
function is_close_enough (x, y, max_pct) {
return 100 - pct_diff(x, y) <= ((typeof max_pct == "undefined") ? 1.0 : max_pct);
}

// return true if x is "within" max_delta of y
function is_within (x, y, max_delta) {
return Math.abs(x - y) < max_delta;
}

Loading…
Cancel
Save