diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-02 16:00:48 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-04 06:58:03 +0100 |
| commit | 06c0defb8b63ba7cdb43ed674beb1cd97847479e (patch) | |
| tree | 333b171d46566c8005f0c2d056ffe0a876257626 /src/timer.cpp | |
| parent | 167c59e2d363ddf609c4e1b6190cb43eeef24637 (diff) | |
a?
Diffstat (limited to 'src/timer.cpp')
| -rw-r--r-- | src/timer.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/timer.cpp b/src/timer.cpp index 8e9ed917..f67d7324 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -46,8 +46,21 @@ uint64_t Time::init() noexcept { return get_time(); } bool Time::operator==(const Time&) const noexcept = default; std::strong_ordering Time::operator<=>(const Time&) const noexcept = default; -float Time::to_seconds(const Ns& ts) noexcept { return float{ts} * 1e-9f; } -float Time::to_milliseconds(const Ns& ts) noexcept { return float{ts} * 1e-6f; } +double Time::to_seconds(const Ns& ts) noexcept +{ + auto x1 = double{ts}; + auto x2 = x1 * 1e-9; + fm_assert(x2 < double{1 << 24}); + return (float)x2; +} + +double Time::to_milliseconds(const Ns& ts) noexcept +{ + auto x1 = double{ts}; + auto x2 = x1 * 1e-6; + fm_assert(x2 < double{1 << 24}); + return (float)x2; +} const char* format_datetime_to_string(char (&buf)[fm_DATETIME_BUF_SIZE]) { |
