From cf56c82e069b37624978a3c2d172ef6e7448baa4 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Thu, 12 Mar 2026 23:24:49 +0100 Subject: [PATCH] size: Implement __floordiv__() Signed-off-by: Robert Baldyga --- type_def/size.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/type_def/size.py b/type_def/size.py index af8b0ed..92f4ffb 100644 --- a/type_def/size.py +++ b/type_def/size.py @@ -191,6 +191,15 @@ def __truediv__(self, other: float | int | Size): raise ValueError("Divisor must not be equal to 0.") return Size(math.ceil(self.get_value() / other)) + @multimethod + def __floordiv__(self, other: float | int | Size): + if isinstance(other, Size): + other = other.get_value() + return math.floor(self.get_value() / other) + if other == 0: + raise ValueError("Divisor must not be equal to 0.") + return Size(math.floor(self.get_value() / other)) + def set_unit(self, new_unit: Unit): new_size = Size(self.get_value(target_unit=new_unit), unit=new_unit)