From 0753d62e98f70043a98273507adaf7aaeed52572 Mon Sep 17 00:00:00 2001 From: Pavel Date: Sat, 26 Sep 2020 22:03:47 +0200 Subject: [PATCH] update cout --- labygui.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/labygui.py b/labygui.py index bda96c5..91fb1d7 100644 --- a/labygui.py +++ b/labygui.py @@ -135,7 +135,15 @@ def fix_angle(a): return a * 2 * asin(1) / pi def cout(x): - return len(str(round(abs(x)/1.,5))) + n, c = 5, 1 + x = round(abs(x) * 10**n) + if x: + c = max(n + 1 - len(str(x)), 0) + while n and not (x % 10): + x = x // 10 + n -= 1 + c += not n + return 1 + len(str(x)) + c def tourner(a): global state