tools: Added IEEE 756 floating point number tester
This commit is contained in:
parent
efed07ac8b
commit
f1b2d5881e
@ -72,6 +72,18 @@ namespace hex {
|
||||
return (value ^ mask) - mask;
|
||||
}
|
||||
|
||||
template<hex::integral T>
|
||||
constexpr inline T swapBitOrder(size_t numBits, T value) {
|
||||
T result = 0x00;
|
||||
|
||||
for (size_t bit = 0; bit < numBits; bit++) {
|
||||
result <<= 1;
|
||||
result |= (value & (1 << bit)) != 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
struct overloaded : Ts... { using Ts::operator()...; };
|
||||
template<class... Ts>
|
||||
|
@ -134,4 +134,6 @@ namespace ImGui {
|
||||
bool InputScalarCallback(const char* label, ImGuiDataType data_type, void* p_data, const char* format, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data);
|
||||
|
||||
void HideTooltip();
|
||||
|
||||
bool BitCheckbox(const char* label, bool* v);
|
||||
}
|
@ -590,4 +590,47 @@ namespace ImGui {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool BitCheckbox(const char* label, bool* v) {
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
const ImVec2 size = ImVec2(CalcTextSize("0").x + style.FramePadding.x * 2, GetFrameHeight());
|
||||
const ImVec2 pos = window->DC.CursorPos;
|
||||
const ImRect total_bb(pos, pos + size);
|
||||
ItemSize(total_bb, style.FramePadding.y);
|
||||
if (!ItemAdd(total_bb, id))
|
||||
{
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
|
||||
if (pressed)
|
||||
{
|
||||
*v = !(*v);
|
||||
MarkItemEdited(id);
|
||||
}
|
||||
|
||||
const ImRect check_bb(pos, pos + size);
|
||||
RenderNavHighlight(total_bb, id);
|
||||
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
|
||||
RenderText(check_bb.Min + style.FramePadding, *v ? "1" : "0");
|
||||
|
||||
ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
|
||||
if (label_size.x > 0.0f)
|
||||
RenderText(label_pos, label);
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
||||
return pressed;
|
||||
}
|
||||
|
||||
}
|
@ -84,7 +84,7 @@ namespace hex::plugin::builtin {
|
||||
[](auto buffer, auto endian, auto style) {
|
||||
hex::unused(endian, style);
|
||||
|
||||
std::string binary = hex::format("0b{:b}", buffer[0]);
|
||||
std::string binary = hex::format("0b{:08b}", buffer[0]);
|
||||
|
||||
return [binary] {
|
||||
ImGui::TextUnformatted(binary.c_str());
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -641,6 +641,20 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.tools.file_tools.combiner.error.open_output", "Erstellen der Zieldatei fehlgeschlagen" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.open_input", "Öffnen der Inputdatei {0} fehlgeschlagen" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.success", "Dateien erfolgreich kombiniert!" },
|
||||
{ "hex.builtin.tools.ieee756", "IEEE 756 Fliesskommazahl Tester" },
|
||||
{ "hex.builtin.tools.ieee756.sign", "Vorzeichen" },
|
||||
{ "hex.builtin.tools.ieee756.exponent", "Exponent" },
|
||||
{ "hex.builtin.tools.ieee756.mantissa", "Mantisse" },
|
||||
{ "hex.builtin.tools.ieee756.exponent_size", "Exponentengrösse" },
|
||||
{ "hex.builtin.tools.ieee756.mantissa_size", "Mantissengrösse" },
|
||||
{ "hex.builtin.tools.ieee756.half_precision", "Half Precision" },
|
||||
{ "hex.builtin.tools.ieee756.singe_precision", "Single Precision" },
|
||||
{ "hex.builtin.tools.ieee756.double_precision", "Double Precision" },
|
||||
{ "hex.builtin.tools.ieee756.type", "Typ" },
|
||||
{ "hex.builtin.tools.ieee756.formula", "Formel" },
|
||||
{ "hex.builtin.tools.ieee756.result.title", "Resultat" },
|
||||
{ "hex.builtin.tools.ieee756.result.float", "Fliesskomma Resultat" },
|
||||
{ "hex.builtin.tools.ieee756.result.hex", "Hexadezimal Resultat" },
|
||||
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "Kürzlich geöffnete Dateien" },
|
||||
|
@ -645,6 +645,20 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.tools.file_tools.combiner.error.open_output", "Failed to create output file" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.open_input", "Failed to open input file {0}" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.success", "Files combined successfully!" },
|
||||
{ "hex.builtin.tools.ieee756", "IEEE 756 Floating Point Tester" },
|
||||
{ "hex.builtin.tools.ieee756.sign", "Sign" },
|
||||
{ "hex.builtin.tools.ieee756.exponent", "Exponent" },
|
||||
{ "hex.builtin.tools.ieee756.mantissa", "Mantissa" },
|
||||
{ "hex.builtin.tools.ieee756.exponent_size", "Exponent Size" },
|
||||
{ "hex.builtin.tools.ieee756.mantissa_size", "Mantissa Size" },
|
||||
{ "hex.builtin.tools.ieee756.half_precision", "Half Precision" },
|
||||
{ "hex.builtin.tools.ieee756.singe_precision", "Single Precision" },
|
||||
{ "hex.builtin.tools.ieee756.double_precision", "Double Precision" },
|
||||
{ "hex.builtin.tools.ieee756.type", "Type" },
|
||||
{ "hex.builtin.tools.ieee756.formula", "Formula" },
|
||||
{ "hex.builtin.tools.ieee756.result.title", "Result" },
|
||||
{ "hex.builtin.tools.ieee756.result.float", "Floating Point Result" },
|
||||
{ "hex.builtin.tools.ieee756.result.hex", "Hexadecimal Result" },
|
||||
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "Recent Files" },
|
||||
|
@ -646,6 +646,20 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.tools.file_tools.combiner.error.open_output", "Impossibile creare file di output" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.open_input", "Impossibile aprire file di input {0}" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.success", "File combinato con successo!" },
|
||||
//{ "hex.builtin.tools.ieee756", "IEEE 756 Floating Point Tester" },
|
||||
//{ "hex.builtin.tools.ieee756.sign", "Sign" },
|
||||
//{ "hex.builtin.tools.ieee756.exponent", "Exponent" },
|
||||
//{ "hex.builtin.tools.ieee756.mantissa", "Mantissa" },
|
||||
//{ "hex.builtin.tools.ieee756.exponent_size", "Exponent Size" },
|
||||
//{ "hex.builtin.tools.ieee756.mantissa_size", "Mantissa Size" },
|
||||
//{ "hex.builtin.tools.ieee756.half_precision", "Half Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.singe_precision", "Single Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.double_precision", "Double Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.type", "Type" },
|
||||
//{ "hex.builtin.tools.ieee756.formula", "Formula" },
|
||||
//{ "hex.builtin.tools.ieee756.result.title", "Result" },
|
||||
//{ "hex.builtin.tools.ieee756.result.float", "Floating Point Result" },
|
||||
//{ "hex.builtin.tools.ieee756.result.hex", "Hexadecimal Result" },
|
||||
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "File recenti" },
|
||||
|
@ -646,6 +646,20 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.tools.file_tools.combiner.error.open_output", "出力ファイルを作成できませんでした" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.open_input", "入力ファイル {0} を開けませんでした" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.success", "ファイルの結合に成功しました!" },
|
||||
//{ "hex.builtin.tools.ieee756", "IEEE 756 Floating Point Tester" },
|
||||
//{ "hex.builtin.tools.ieee756.sign", "Sign" },
|
||||
//{ "hex.builtin.tools.ieee756.exponent", "Exponent" },
|
||||
//{ "hex.builtin.tools.ieee756.mantissa", "Mantissa" },
|
||||
//{ "hex.builtin.tools.ieee756.exponent_size", "Exponent Size" },
|
||||
//{ "hex.builtin.tools.ieee756.mantissa_size", "Mantissa Size" },
|
||||
//{ "hex.builtin.tools.ieee756.half_precision", "Half Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.singe_precision", "Single Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.double_precision", "Double Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.type", "Type" },
|
||||
//{ "hex.builtin.tools.ieee756.formula", "Formula" },
|
||||
//{ "hex.builtin.tools.ieee756.result.title", "Result" },
|
||||
//{ "hex.builtin.tools.ieee756.result.float", "Floating Point Result" },
|
||||
//{ "hex.builtin.tools.ieee756.result.hex", "Hexadecimal Result" },
|
||||
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "最近開いたファイル" },
|
||||
|
@ -639,6 +639,20 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.tools.file_tools.combiner.error.open_output", "创建输出文件失败!" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.open_input", "打开输入文件 {0} 失败" },
|
||||
{ "hex.builtin.tools.file_tools.combiner.success", "文件合并成功!" },
|
||||
//{ "hex.builtin.tools.ieee756", "IEEE 756 Floating Point Tester" },
|
||||
//{ "hex.builtin.tools.ieee756.sign", "Sign" },
|
||||
//{ "hex.builtin.tools.ieee756.exponent", "Exponent" },
|
||||
//{ "hex.builtin.tools.ieee756.mantissa", "Mantissa" },
|
||||
//{ "hex.builtin.tools.ieee756.exponent_size", "Exponent Size" },
|
||||
//{ "hex.builtin.tools.ieee756.mantissa_size", "Mantissa Size" },
|
||||
//{ "hex.builtin.tools.ieee756.half_precision", "Half Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.singe_precision", "Single Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.double_precision", "Double Precision" },
|
||||
//{ "hex.builtin.tools.ieee756.type", "Type" },
|
||||
//{ "hex.builtin.tools.ieee756.formula", "Formula" },
|
||||
//{ "hex.builtin.tools.ieee756.result.title", "Result" },
|
||||
//{ "hex.builtin.tools.ieee756.result.float", "Floating Point Result" },
|
||||
//{ "hex.builtin.tools.ieee756.result.hex", "Hexadecimal Result" },
|
||||
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "最近文件" },
|
||||
|
Loading…
Reference in New Issue
Block a user