mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
consider double epsilon when comapring crystal values
This commit is contained in:
parent
b281079d73
commit
fdc9f38a8e
@ -48,6 +48,9 @@
|
|||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
|
|
||||||
|
#include <cfloat>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
|
||||||
// This array *must* stay in order, it's binary-searched
|
// This array *must* stay in order, it's binary-searched
|
||||||
const double XTAL::known_xtals[] = {
|
const double XTAL::known_xtals[] = {
|
||||||
@ -380,8 +383,9 @@ bool XTAL::validate(double base_clock)
|
|||||||
if(slot > last_index)
|
if(slot > last_index)
|
||||||
slot = slot ^ (step | (step >> 1));
|
slot = slot ^ (step | (step >> 1));
|
||||||
else {
|
else {
|
||||||
double sfreq = known_xtals[slot];
|
const double sfreq = known_xtals[slot];
|
||||||
if(base_clock == sfreq) {
|
const double diff = std::abs((base_clock - sfreq) / base_clock);
|
||||||
|
if(diff <= (2 * DBL_EPSILON)) {
|
||||||
last_correct_value = base_clock;
|
last_correct_value = base_clock;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user