diff options
| author | 2018-06-25 14:35:04 +1000 | |
|---|---|---|
| committer | 2018-06-25 14:35:04 +1000 | |
| commit | fdc9f38a8ee3e520339af0409bc7ced172a8acf9 (patch) | |
| tree | 17f65cf97e2b8341f6653c7e330716dd78cc5ad9 /src | |
| parent | b281079d73b520e54a0e8f8c81dacc98314f2b08 (diff) | |
consider double epsilon when comapring crystal values
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/xtal.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/emu/xtal.cpp b/src/emu/xtal.cpp index b48ba2791c6..3c1f71d7cac 100644 --- a/src/emu/xtal.cpp +++ b/src/emu/xtal.cpp @@ -48,6 +48,9 @@ #include "emu.h" +#include <cfloat> +#include <cmath> + // This array *must* stay in order, it's binary-searched const double XTAL::known_xtals[] = { @@ -380,8 +383,9 @@ bool XTAL::validate(double base_clock) if(slot > last_index) slot = slot ^ (step | (step >> 1)); else { - double sfreq = known_xtals[slot]; - if(base_clock == sfreq) { + const double sfreq = known_xtals[slot]; + const double diff = std::abs((base_clock - sfreq) / base_clock); + if(diff <= (2 * DBL_EPSILON)) { last_correct_value = base_clock; return true; } |
