Repository: frequenz-floss/frequenz-sdk-python
Issue: Percentage.from_percent(0).__str__() raising exception due to `math.log10(0)`?

### What happened?

Raising an exception:

```
  File "/home/christianparpart/work/frequenz-actor-fcr-prequalifying/src/frequenz/actor/fcr_prequalifying/prequalification.py", line 299, in prequalify
    LOGGER.info("Preparing battery to %s SoC", preparation_target_soc)
  File "/usr/lib64/python3.11/logging/__init__.py", line 1489, in info
    self._log(INFO, msg, args, **kwargs)
  File "/usr/lib64/python3.11/logging/__init__.py", line 1634, in _log
    self.handle(record)
  File "/usr/lib64/python3.11/logging/__init__.py", line 1644, in handle
    self.callHandlers(record)
  File "/usr/lib64/python3.11/logging/__init__.py", line 1706, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python3.11/logging/__init__.py", line 978, in handle
    self.emit(record)
  File "/home/christianparpart/work/frequenz-actor-fcr-prequalifying/.nox/pytest/lib/python3.11/site-packages/_pytest/logging.py", line 372, in emit
    super().emit(record)
  File "/usr/lib64/python3.11/logging/__init__.py", line 1118, in emit
    self.handleError(record)
  File "/usr/lib64/python3.11/logging/__init__.py", line 1110, in emit
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/logging/__init__.py", line 953, in format
    return fmt.format(record)
           ^^^^^^^^^^^^^^^^^^
  File "/home/christianparpart/work/frequenz-actor-fcr-prequalifying/.nox/pytest/lib/python3.11/site-packages/_pytest/logging.py", line 136, in format
    return super().format(record)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/logging/__init__.py", line 687, in format
    record.message = record.getMessage()
                     ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/logging/__init__.py", line 377, in getMessage
    msg = msg % self.args
          ~~~~^~~~~~~~~~~
  File "/home/christianparpart/work/frequenz-actor-fcr-prequalifying/.nox/pytest/lib/python3.11/site-packages/frequenz/sdk/timeseries/_quantities.py", line 116, in __str__
    return self.__format__("")
           ^^^^^^^^^^^^^^^^^^^
  File "/home/christianparpart/work/frequenz-actor-fcr-prequalifying/.nox/pytest/lib/python3.11/site-packages/frequenz/sdk/timeseries/_quantities.py", line 167, in __format__
    exponent = math.floor(math.log10(abs_value))
                          ^^^^^^^^^^^^^^^^^^^^^
ValueError: math domain error
```

`abs_value` should be `0` in my case :)

### What did you expect instead?

`"0%"`

### Affected version(s)

v0.22.0

### Affected part(s)

Actors or actors utilities (decorator, etc.) (part:actor), Core components (data structures, etc.) (part:core)

### Extra information

_No response_

Changed files:
src/frequenz/sdk/timeseries/_quantities.py, tests/timeseries/test_quantities.py

diff --git a/src/frequenz/sdk/timeseries/_quantities.py b/src/frequenz/sdk/timeseries/_quantities.py
index 0b2b99e..192517c 100644
--- a/src/frequenz/sdk/timeseries/_quantities.py
+++ b/src/frequenz/sdk/timeseries/_quantities.py
@@ -164,7 +164,7 @@ class Quantity:
             return f"{self._base_value:.{precision}f}"
 
         abs_value = abs(self._base_value)
-        exponent = math.floor(math.log10(abs_value))
+        exponent = math.floor(math.log10(abs_value)) if abs_value else 0
         unit_place = exponent - exponent % 3
         if unit_place < min(self._exponent_unit_map):
             unit = self._exponent_unit_map[min(self._exponent_unit_map.keys())]
diff --git a/tests/timeseries/test_quantities.py b/tests/timeseries/test_quantities.py
index 827fc33..5dd9e96 100644
--- a/tests/timeseries/test_quantities.py
+++ b/tests/timeseries/test_quantities.py
@@ -84,6 +84,11 @@ def test_string_representation() -> None:
     assert f"{Fz1(1.024445, exponent=-12)}" == "0 Hz"
     assert f"{Fz2(1.024445, exponent=-12)}" == "0 Hz"
 
+    assert f"{Fz1(0)}" == "0 Hz"
+
+    assert f"{Fz1(-20)}" == "-20 Hz"
+    assert f"{Fz1(-20000)}" == "-20 kHz"
+
 
 def test_addition_subtraction() -> None:
     """Test the addition and subtraction of the quantities."""