efiWatchdog: avoid converting time to float (#4562)
https://stackoverflow.com/questions/68690961/why-does-converting-int-to-float-lose-precision-in-c-programming-language
This commit is contained in:
parent
2eca6ec3c7
commit
19226cb656
|
@ -454,13 +454,12 @@ void Engine::efiWatchdog() {
|
||||||
if (engine->configBurnTimer.hasElapsedSec(5) && engineConfiguration->tempBooleanForVerySpecialLogic) {
|
if (engine->configBurnTimer.hasElapsedSec(5) && engineConfiguration->tempBooleanForVerySpecialLogic) {
|
||||||
static efitimems_t mostRecentMs = 0;
|
static efitimems_t mostRecentMs = 0;
|
||||||
|
|
||||||
float msNow = currentTimeMillis();
|
efitimems_t msNow = currentTimeMillis();
|
||||||
if (msNow != 0) {
|
if (mostRecentMs != 0) {
|
||||||
float gapInMs = msNow - mostRecentMs;
|
efitimems_t gapInMs = msNow - mostRecentMs;
|
||||||
if (gapInMs > 500) {
|
if (gapInMs > 500) {
|
||||||
// float has 24 bits in the mantissa, which should allow up to 8 significant figures
|
firmwareError(WATCH_DOG_SECONDS, "gap in time: now=%d mS, was %d mS, gap=%dmS",
|
||||||
// we loose precision here after about 1,000,000 seconds which is 11 days
|
msNow, mostRecentMs, gapInMs);
|
||||||
firmwareError(WATCH_DOG_SECONDS, "gap in time: now=%fms gap=%fms", msNow, gapInMs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mostRecentMs = msNow;
|
mostRecentMs = msNow;
|
||||||
|
|
Loading…
Reference in New Issue