InputDouble disallows inf and nan input #7096

Closed
opened 2023-12-07 02:18:19 +00:00 by PeterJohnson · 0 comments
PeterJohnson commented 2023-12-07 02:18:19 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version: 64b1e448d2
Branch: docking

My Issue/Question:

InputDouble() does not allow inf or nan be input, despite these being recognized by sscanf() (see https://en.cppreference.com/w/cpp/string/byte/strtof) and output by printf(). This means an infinity/NaN value can be displayed, but not set. This is caused by ImGuiInputTextFlags_CharsScientific not allowing these characters: ocornut/imgui@d72e1563d4/imgui_widgets.cpp (L3985C9-L3987C27)

A workaround is to use InputScalar() and not setting ImGuiInputTextFlags_CharsScientific.

Standalone, minimal, complete and verifiable example:

ImGui::Begin("Example Bug");
double v = std::numeric_limits<double>::infinity();
InputDouble("test", &v);
ImGui::End();
**Version/Branch of Dear ImGui:** Version: 64b1e448d20c9be9275af731c34b4c7bf14a8e95 Branch: docking **My Issue/Question:** `InputDouble()` does not allow `inf` or `nan` be input, despite these being recognized by `sscanf()` (see https://en.cppreference.com/w/cpp/string/byte/strtof) and output by `printf()`. This means an infinity/NaN value can be displayed, but not set. This is caused by `ImGuiInputTextFlags_CharsScientific` not allowing these characters: https://github.com/ocornut/imgui/blob/d72e1563d4274e0f1a21973cf2d98563d579d377/imgui_widgets.cpp#L3985C9-L3987C27 A workaround is to use `InputScalar()` and not setting `ImGuiInputTextFlags_CharsScientific`. **Standalone, minimal, complete and verifiable example:** ``` ImGui::Begin("Example Bug"); double v = std::numeric_limits<double>::infinity(); InputDouble("test", &v); ImGui::End(); ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#7096
No description provided.