mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
attotime: simpler from_hz (nw)
This commit is contained in:
parent
9df6cfe087
commit
60c4816861
@ -137,10 +137,10 @@ public:
|
|||||||
/** Create an attotime from a integer count of nanoseconds @nsec */
|
/** Create an attotime from a integer count of nanoseconds @nsec */
|
||||||
static constexpr attotime from_nsec(s64 nsec) { return attotime(nsec / 1000000000, (nsec % 1000000000) * (ATTOSECONDS_PER_SECOND / 1000000000)); }
|
static constexpr attotime from_nsec(s64 nsec) { return attotime(nsec / 1000000000, (nsec % 1000000000) * (ATTOSECONDS_PER_SECOND / 1000000000)); }
|
||||||
/** Create an attotime from at the given frequency @frequency */
|
/** Create an attotime from at the given frequency @frequency */
|
||||||
static attotime from_hz(double frequency) { assert(frequency > 0); double d = 1 / frequency; return attotime(floor(d), modf(d, &d) * ATTOSECONDS_PER_SECOND); }
|
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(u32 frequency) { return from_hz(double(frequency)); }
|
static attotime from_hz(int frequency) { return (frequency > 0) ? from_hz(u32(frequency)) : attotime::never; }
|
||||||
static attotime from_hz(int frequency) { return from_hz(double(frequency)); }
|
static attotime from_hz(const XTAL &xtal) { return from_hz(xtal.value()); }
|
||||||
static attotime from_hz(const XTAL &xtal) { return 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; }
|
||||||
|
|
||||||
// math
|
// math
|
||||||
attotime &operator+=(const attotime &right);
|
attotime &operator+=(const attotime &right);
|
||||||
|
Loading…
Reference in New Issue
Block a user