Skip to content

Commit

Permalink
feat: Added a quarter precision (8 bits) button to IEEE 745 tool (#1868)
Browse files Browse the repository at this point in the history
Per discussions on Discord.
  • Loading branch information
paxcut authored Sep 15, 2024
1 parent 0b2eca3 commit a587c5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions plugins/builtin/romfs/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 14 additions & 6 deletions plugins/builtin/source/content/tools/ieee_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a587c5f

Please sign in to comment.