1
0
mirror of synced 2024-11-27 17:10:51 +01:00

feat: Added a quarter precision (8 bits) button to IEEE 745 tool (#1868)

Per discussions on Discord.
This commit is contained in:
paxcut 2024-09-15 06:22:35 -07:00 committed by GitHub
parent 0b2eca3066
commit a587c5ff74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View File

@ -636,6 +636,7 @@
"hex.builtin.tools.ieee754.mantissa_size": "Mantissa Size",
"hex.builtin.tools.ieee754.result.float": "Floating Point Result",
"hex.builtin.tools.ieee754.result.hex": "Hexadecimal Result",
"hex.builtin.tools.ieee754.quarter_precision": "Quarter Precision",
"hex.builtin.tools.ieee754.result.title": "Result",
"hex.builtin.tools.ieee754.settings.display_mode.detailed": "Detailed",
"hex.builtin.tools.ieee754.settings.display_mode.simplified": "Simplified",

View File

@ -24,12 +24,7 @@ namespace hex::plugin::builtin {
class IEEE754STATICS {
public:
IEEE754STATICS() {
value = 0;
exponentBitCount = 8;
mantissaBitCount = 23;
resultFloat = 0;
}
IEEE754STATICS() : value(0), exponentBitCount(8), mantissaBitCount(23), resultFloat(0) {}
u128 value;
i32 exponentBitCount;
@ -567,6 +562,19 @@ namespace hex::plugin::builtin {
auto color = ImGui::GetColorU32(ImGuiCol_ButtonActive);
bool needsPop = false;
if (ieee754statics.exponentBitCount == 3 && ieee754statics.mantissaBitCount == 4) {
ImGui::PushStyleColor(ImGuiCol_Button, color);
needsPop = true;
}
if (ImGui::Button("hex.builtin.tools.ieee754.quarter_precision"_lang)) {
ieee754statics.exponentBitCount = 3;
ieee754statics.mantissaBitCount = 4;
inputFieldWidth = 0;
}
if (needsPop) ImGui::PopStyleColor();
ImGui::SameLine();
needsPop = false;
if (ieee754statics.exponentBitCount == 5 && ieee754statics.mantissaBitCount == 10) {
ImGui::PushStyleColor(ImGuiCol_Button, color);
needsPop = true;