From 7edd2b1f12b352f3b7fce9480110bd90cd17bc1f Mon Sep 17 00:00:00 2001 From: slowriot Date: Thu, 3 Sep 2026 14:42:24 +0100 Subject: [PATCH] Sliders, Drags: adjust ScaleValueFromRatioT() to increase remapping precision (in theory). (#9536) Omar: couldn't detect any output difference in test suite with large u64/s64 ranges drag/sliders. I believe this is entirely theoretical and it's principal value is to shut Linter warnings --- imgui_widgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 2a207f6f0..65d131fb6 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3091,7 +3091,7 @@ TYPE ImGui::ScaleValueFromRatioT(ImGuiDataType data_type, float t, TYPE v_min, T // This code is carefully tuned to work with large values (e.g. high ranges of U64) while preserving this property.. // - Not doing a *1.0 multiply at the end of a range as it tends to be lossy. While absolute aiming at a large s64/u64 // range is going to be imprecise anyway, with this check we at least make the edge values matches expected limits. - FLOATTYPE v_new_off_f = (SIGNEDTYPE)(v_max - v_min) * t; + FLOATTYPE v_new_off_f = (FLOATTYPE)(SIGNEDTYPE)(v_max - v_min) * (FLOATTYPE)t; result = (TYPE)((SIGNEDTYPE)v_min + (SIGNEDTYPE)(v_new_off_f + (FLOATTYPE)(v_min > v_max ? -0.5 : 0.5))); } }