diff options
author | hap <happppp@users.noreply.github.com> | 2018-11-07 22:45:16 +0100 |
---|---|---|
committer | hap <happppp@users.noreply.github.com> | 2018-11-07 22:45:16 +0100 |
commit | ba8aba7ba36aa6aa0ed58ef93ab295a9f39813a7 (patch) | |
tree | 3578e153e593cfd666f9af0a9ece50212c361ef2 | |
parent | 64e4d5eabae35d8227e8479128d9eb6b5b843739 (diff) |
attotime from_hz(double): simpler calculation if more than 1Hz (nw)
-rw-r--r-- | src/emu/attotime.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/emu/attotime.h b/src/emu/attotime.h index 4d79339db06..438ba963f44 100644 --- a/src/emu/attotime.h +++ b/src/emu/attotime.h @@ -140,7 +140,18 @@ public: static attotime from_hz(u32 frequency) { return (frequency > 1) ? attotime(0, HZ_TO_ATTOSECONDS(frequency)) : (frequency == 1) ? attotime(1, 0) : attotime::never; } static attotime from_hz(int frequency) { return (frequency > 0) ? from_hz(u32(frequency)) : attotime::never; } static attotime from_hz(const XTAL &xtal) { return (xtal.dvalue() > 1.0) ? attotime(0, HZ_TO_ATTOSECONDS(xtal)) : from_hz(xtal.dvalue()); } - static attotime from_hz(double frequency) { if (frequency > 0.0) { double i, f = modf(1.0 / frequency, &i); return attotime(i, f * ATTOSECONDS_PER_SECOND); } else return attotime::never; } + static attotime from_hz(double frequency) + { + if (frequency > 1.0) + return attotime(0, HZ_TO_ATTOSECONDS(frequency)); + else if (frequency > 0.0) + { + double i, f = modf(1.0 / frequency, &i); + return attotime(i, f * ATTOSECONDS_PER_SECOND); + } + else + return attotime::never; + } // math attotime &operator+=(const attotime &right); |