Update size conversion methods
This commit is contained in:
parent
acc305d3db
commit
4f1e263708
1 changed files with 8 additions and 8 deletions
16
src/misc.gd
16
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.
|
## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded.
|
||||||
@warning_ignore("integer_division")
|
@warning_ignore("integer_division")
|
||||||
func byte2mib(bytes: int, flatten: bool = true) -> float:
|
func byte2mib(bytes: int, flatten: bool = true) -> float:
|
||||||
if flatten: return bytes/1048576
|
if flatten: return float(int(float(bytes)/1048576.0))
|
||||||
return bytes/float(1048576)
|
return float(bytes)/1048576.0
|
||||||
|
|
||||||
## Converts a number of mebibytes into bytes.[br]
|
## Converts a number of mebibytes into bytes.[br]
|
||||||
## [br]
|
## [br]
|
||||||
## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded.
|
## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded.
|
||||||
func mib2byte(mib: float, flatten: bool = true) -> float:
|
func mib2byte(mib: float, flatten: bool = true) -> float:
|
||||||
if flatten: return int(mib*1048576)
|
if flatten: return float(int(mib*1048576.0))
|
||||||
return mib*1048576
|
return mib*1048576.0
|
||||||
|
|
||||||
## Converts a number of mebibytes into gibibytes.[br]
|
## Converts a number of mebibytes into gibibytes.[br]
|
||||||
## [br]
|
## [br]
|
||||||
## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded.
|
## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded.
|
||||||
func mib2gib(mib: float, flatten: bool = true) -> float:
|
func mib2gib(mib: float, flatten: bool = true) -> float:
|
||||||
if flatten: return int(mib/1024)
|
if flatten: return float(int(mib/1024.0))
|
||||||
return mib/1024
|
return mib/1024.0
|
||||||
|
|
||||||
## Converts a number of gebibytes into mebibytes.[br]
|
## Converts a number of gebibytes into mebibytes.[br]
|
||||||
## [br]
|
## [br]
|
||||||
## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded.
|
## If [code]flatten[/code] is set to [code]true[/code], the decimal part will be discarded.
|
||||||
func gib2mib(gib: float, flatten: bool = true) -> float:
|
func gib2mib(gib: float, flatten: bool = true) -> float:
|
||||||
if flatten: return int(gib*1024)
|
if flatten: return float(int(gib*1024.0))
|
||||||
return gib*1024
|
return gib*1024.0
|
||||||
|
|
||||||
# +++ type formatting +++
|
# +++ type formatting +++
|
||||||
## Converts a string array into a normal, nicely formatted string.[br]
|
## Converts a string array into a normal, nicely formatted string.[br]
|
||||||
|
|
Loading…
Reference in a new issue