bugfix: use under and over uprintable strings

pull/113/head
Holger Mueller 2019-12-08 18:25:15 +01:00
rodzic 6a4800d361
commit bd9287b9b9
1 zmienionych plików z 8 dodań i 9 usunięć

Wyświetl plik

@ -81,19 +81,18 @@ class Value:
abs(self._value) >= 10 ** ((fmt.max_offset + 1) * 3): abs(self._value) >= 10 ** ((fmt.max_offset + 1) * 3):
return (("-" if self._value < 0 else "") + return (("-" if self._value < 0 else "") +
"\N{INFINITY}" + fmt.space_str + self._unit) "\N{INFINITY}" + fmt.space_str + self._unit)
if (self._value < fmt.printable_min or if self._value < fmt.printable_min:
self._value > fmt.printable_max): return fmt.unprintable_under + self._unit
return fmt.unprintable_str + self._unit if self._value > fmt.printable_max:
return fmt.unprintable_over + self._unit
if self._value == 0: if self._value == 0:
offset = 0 offset = 0
else: else:
offset = int(math.log10(abs(self._value)) // 3) offset = clamp_value(
int(math.log10(abs(self._value)) // 3),
if offset < fmt.min_offset: fmt.min_offset,
offset = fmt.min_offset fmt.max_offset)
elif offset > fmt.max_offset:
offset = fmt.max_offset
real = float(self._value) / (10 ** (offset * 3)) real = float(self._value) / (10 ** (offset * 3))