Skip to content

File Size

Irtsa edited this page Feb 22, 2025 · 2 revisions

Given a filename (assuming it is a binary file), it will return what should be the the size of the binary file.


Source Code

fileSize = function(filename)
    num = 0
    for i in range(0, filename.len - 1)
        num = num + (filename[i].code * (i + 1))
    end for
    num = floor(110000 + 6990000 * (num % 1000 / 1000)) + num % 10

    Names = ["b", "Kb", "Mb", "Gb"]
    n = floor(num ^ 0.1 / 3) + 1
    return round(num / (1000 ^ n), 2) + Names[n]
end function
Clone this wiki locally