From 0e0afa60fca475b5856b99f9c775f4b97f44c310 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sat, 10 Feb 2024 18:48:37 +0100 Subject: [PATCH] Update conversion functions --- src/misc.gd | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/misc.gd b/src/misc.gd index e5c4439..daab0b4 100644 --- a/src/misc.gd +++ b/src/misc.gd @@ -33,11 +33,14 @@ func byte2mib(bytes: int, flatten: bool = true) -> float: if flatten: return bytes/1048576 return bytes/float(1048576) -func mib2byte(mib: int) -> int: return mib*1048576 +func mib2byte(mib: float, flatten: bool = true) -> float: + if flatten: return int(mib*1048576) + return mib*1048576 -@warning_ignore("integer_division") func mib2gib(mib: float, flatten: bool = true) -> float: - if flatten: return int(mib)/1024 - return mib/float(1024) + if flatten: return int(mib/1024) + return mib/1024 -func gib2mib(gib: float) -> float: return gib*1024 +func gib2mib(gib: float, flatten: bool = true) -> float: + if flatten: return int(gib*1024) + return gib*1024