From 3a0f4409fc2e433f151a798b0db5cbd506c63430 Mon Sep 17 00:00:00 2001 From: matusm1 <55785757+matusm1@users.noreply.github.com> Date: Thu, 3 Nov 2022 23:02:24 +0100 Subject: [PATCH] Precision errors in float to string methods (#7809) * replaced fixValue with autoFixed * Reverted, only fixValue implementation --- core/src/mindustry/world/meta/StatValues.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/mindustry/world/meta/StatValues.java b/core/src/mindustry/world/meta/StatValues.java index b7b21fb98b..c5c0adf874 100644 --- a/core/src/mindustry/world/meta/StatValues.java +++ b/core/src/mindustry/world/meta/StatValues.java @@ -35,8 +35,7 @@ public class StatValues{ } public static String fixValue(float value){ - int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2; - return Strings.fixed(value, precision); + return Strings.autoFixed(value, 2); } public static StatValue squared(float value, StatUnit unit){