Update size conversion methods

This commit is contained in:
JeremyStar™ 2024-04-25 20:20:57 +02:00
parent acc305d3db
commit 4f1e263708
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -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]