The JS code is as follows:
var size = ' 8164674 '; function bytestosize (bytes) { ifreturn ' 0 B '; var // or 1024x768 sizes = [' B ', ' KB ', ' MB ', ' GB ', ' TB ', ' PB ', ' EB ', ' ZB ', ' YB '], = Math.floor (Math.log (bytes)/ Math.lo G (k)); return (Bytes/math.pow (k, i)). Toprecision (3) + "+ Sizes[i];} Console.log (Bytestosize (parseint (size)));
Summarize
The next two storage units are described: Bits, bytes
Bit: "Bit" is the smallest unit of data in an electronic computer. The status of each bit can only be 0 or 1.
Word: "word" consists of a number of bytes, the number of bits is called word length, different grades of machines have different length of words. For example, a 8-bit machine, its 1 characters equals 1 bytes, and the word length is 8 bits.
KB: is 1024 bytes
MB: Is 1024 kb
GB: is 1024 MB
TB: is 1024 GB
Common conversion units 1, bit, and byte conversions
1 bit (bits or bit) equals 0.125B (byte byte)
1 B (byte byte) equals 8 bit (bit or bit)
2, megabytes and kilobytes
1KB (kilobyte kb) equals 0.0009765625 MB (MBytes)
1MB (MBytes) equals 1024KB (kilobyte KB)
3, megabytes and gigabytes
1MB (MBytes) equals L 0.0009765625 GB (Kbytes)
1GB (gigabyte) equals 1024MB (MBytes)
JS Data Capacity Unit conversion (KB,MB,GB,TB)