Created
December 8, 2015 22:55
-
-
Save Vaguery/f132946f4382db375cee to your computer and use it in GitHub Desktop.
I feel dirty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;... | |
| ;; (:import [org.apfloat Apfloat ApfloatMath]) | |
| (def precision 100) | |
| ;;... | |
| (defn pretty-much-equal? | |
| "takes two Apfloat items, subtracts one from the other, and returns `true` if the absolute difference is less a threshold set to half the current precision" | |
| [num1 num2] | |
| (= -1 (.compareTo | |
| (.subtract num1 num2) | |
| (Apfloat. (str "1e-" (/ precision 2)) precision)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment