core: don't use relative precision when comparing to 0

The FP_IS_SAME macro uses a relative precision to compare
floating points. This fails when comparing to 0. Therefore,
use an absolute precision in this case. Implement as an
inline function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-08-30 17:47:31 +02:00 committed by Robert C. Helling
parent 2ae7f3cf6c
commit 5db4a95a26
3 changed files with 11 additions and 5 deletions

View file

@ -195,7 +195,7 @@ void DownloadFromDCWidget::updateProgressBar()
ui.progressText->setText(progress_bar_text);
#endif
} else {
if (IS_FP_SAME(progress_bar_fraction, 0.0)) {
if (nearly_0(progress_bar_fraction)) {
// while we are waiting to connect, set the maximum to 0 so we get a busy indication
ui.progressBar->setMaximum(0);
ui.progressBar->setFormat(tr("Connecting to dive computer"));