From 4f1e263708b75371e73b8379934b49f96461c33f Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Thu, 25 Apr 2024 20:20:57 +0200 Subject: [PATCH] Update size conversion methods --- src/misc.gd | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/misc.gd b/src/misc.gd index ee92ac0..8cca428 100644 --- a/src/misc.gd +++ b/src/misc.gd @@ -40,29 +40,29 @@ func _pull_config() -> void: ## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded. @warning_ignore("integer_division") func byte2mib(bytes: int, flatten: bool = true) -> float: - if flatten: return bytes/1048576 - return bytes/float(1048576) + if flatten: return float(int(float(bytes)/1048576.0)) + return float(bytes)/1048576.0 ## Converts a number of mebibytes into bytes.[br] ## [br] ## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded. func mib2byte(mib: float, flatten: bool = true) -> float: - if flatten: return int(mib*1048576) - return mib*1048576 + if flatten: return float(int(mib*1048576.0)) + return mib*1048576.0 ## Converts a number of mebibytes into gibibytes.[br] ## [br] ## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded. func mib2gib(mib: float, flatten: bool = true) -> float: - if flatten: return int(mib/1024) - return mib/1024 + if flatten: return float(int(mib/1024.0)) + return mib/1024.0 ## Converts a number of gebibytes into mebibytes.[br] ## [br] ## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded. func gib2mib(gib: float, flatten: bool = true) -> float: - if flatten: return int(gib*1024) - return gib*1024 + if flatten: return float(int(gib*1024.0)) + return gib*1024.0 # +++ type formatting +++ ## Converts a string array into a normal, nicely formatted string.[br]