Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions type_def/size.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading