This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from uurha/dev
Dev
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using UnityEngine; | ||
|
||
namespace Better.Extensions.Runtime | ||
{ | ||
public static class SizeConverter | ||
{ | ||
private const float ConvertRation = 1024f; | ||
|
||
public enum SizeUnits : long | ||
{ | ||
Byte = 0, | ||
Kb = 1, | ||
Mb = 2, | ||
Gb = 3, | ||
Tb = 4, | ||
Pb = 5, | ||
Eb = 6, | ||
Zb = 7, | ||
Yb = 8 | ||
} | ||
|
||
public static double ToSize(this ulong value, SizeUnits unit) | ||
{ | ||
return (value / Mathf.Pow(1024, (long)unit)); | ||
} | ||
|
||
public static double ToSize(this long value, SizeUnits unit) | ||
{ | ||
return (value / Mathf.Pow(1024, (long)unit)); | ||
} | ||
|
||
public static double ToSize(this double value, SizeUnits unit) | ||
{ | ||
return (value / Mathf.Pow(1024, (long)unit)); | ||
} | ||
|
||
public static double ToMegabytes(this ulong bytes) | ||
{ | ||
return bytes.ToSize(SizeUnits.Mb); | ||
} | ||
|
||
public static double ToMegabytes(this double bytes) | ||
{ | ||
return bytes.ToSize(SizeUnits.Mb); | ||
} | ||
|
||
public static double ToMegabytes(this long bytes) | ||
{ | ||
return bytes.ToSize(SizeUnits.Mb); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.