From 1c174cc103cb1b00befed6e52b40bb3e76cc7797 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 26 Apr 2025 14:29:48 -0400 Subject: Use two's complement in number display --- gui/digitlabel.h | 2 +- gui/digitlabelhelper.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'gui') diff --git a/gui/digitlabel.h b/gui/digitlabel.h index 68b01cb..bffdd0a 100644 --- a/gui/digitlabel.h +++ b/gui/digitlabel.h @@ -59,7 +59,7 @@ class DigitLabel : public QLabel /** * If this digit should display in hexidecinmal. */ - int is_hex; + int is_hex = true; /** * If this digit should not display. */ diff --git a/gui/digitlabelhelper.h b/gui/digitlabelhelper.h index a0f845f..715089a 100644 --- a/gui/digitlabelhelper.h +++ b/gui/digitlabelhelper.h @@ -24,7 +24,8 @@ class DigitLabelHelper { public: /** - * Contains the main formatting logic used to format integers. + * Contains the main formatting logic used to format integers. Uses 2's + * complement for hexadecimal numbers. * @param the value to be formated * @param if the value should be displayed in hex. If false, displays in * decimal. @@ -35,7 +36,7 @@ class DigitLabelHelper { if (is_cleared) return QString(); - return is_hex ? QString::number(value, 16).toUpper() + return is_hex ? QString::asprintf("%04X", value) : QString::number(value); } }; -- cgit v1.2.3