Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Main
- Dim rnd As New Random
- Dim numbers=Enumerable.Range(0,18).Select(Function(n) Math.Pow(10,n))
- numbers= numbers.Concat(numbers.Select(Function(x) x+rnd.Next(0,500))).OrderBy(Function(x) x).ToArray.Dump("Numbers")
- numbers.select(Function(n) New With {.Size=BytesToString(CLng(n)),.Number=n.ToString("n0")}).Dump("Log10")
- End Sub
- ' Define other methods and classes here
- Private Function BytesToString(ByVal byteCount As Long) As String
- Dim suf As String() = {"B", "KB", "MB", "GB", "TB", "PB", "EB"}
- If byteCount = 0 Then Return "0" & suf(0)
- Dim bytes As Long = Math.Abs(byteCount)
- Dim place As Integer = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)))
- Dim num As Double = Math.Round(bytes / Math.Pow(1024, place), 1)
- Return (Math.Sign(byteCount) * num).ToString() & suf(place)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement