Bytes Conversion To Kb Downloadbackstage



1 Byte = 8 Bits 1 Kilobyte = 1024 Bytes 1 Megabyte = 1048576 Bytes 1 Gigabyte = Bytes 1 Terabyte = 776 bytes Byte Conversion Compliments of Page One, LCC. Hello Friends, today we are going to see how to convert bytes to kb, mb, gb, tb, pb, eb, zb, yb in javascript. The same feature i was required to add in one of my project to convert size of files uploaded on server through media upload feature just like wordpress. 1 Kilobytes = 1024 Bytes: 10 Kilobytes = 10240 Bytes: 2500 Kilobytes = 2560000 Bytes: 2 Kilobytes = 2048 Bytes: 20 Kilobytes = 20480 Bytes: 5000 Kilobytes = 5120000 Bytes: 3 Kilobytes = 3072 Bytes.

  1. Byte Table Conversion
  2. Bytes To Kilobytes Conversion (B To KB)
  3. Convert Bytes To Mb
Calculator
Bytes converter python3. Convert bytes to KB, MB, GB, TB, PB and explanation on difference between byte, bit, kB, KiB, KB, kb and ko

Byte Table Conversion

byte_converter.py
defget_printable_size(byte_size):
''
A bit is the smallest unit, it's either 0 or 1
1 byte = 1 octet = 8 bits
1 kB = 1 kilobyte = 1000 bytes = 10^3 bytes
1 KiB = 1 kibibyte = 1024 bytes = 2^10 bytes
1 KB = 1 kibibyte OR kilobyte ~= 1024 bytes ~= 2^10 bytes (it usually means 1024 bytes but sometimes it's 1000... ask the sysadmin ;) )
1 kb = 1 kilobits = 1000 bits (this notation should not be used, as it is very confusing)
1 ko = 1 kilooctet = 1000 octets = 1000 bytes = 1 kB
Also Kb seems to be a mix of KB and kb, again it depends on context.
In linux, a byte (B) is composed by a sequence of bits (b). One byte has 256 possible values.
More info : http://www.linfo.org/byte.html
''
BASE_SIZE=1024.00
MEASURE= ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
def_fix_size(size, size_index):
ifnotsize:
return'0'
elifsize_index0:
returnstr(size)
else:
return'{:.3f}'.format(size)
current_size=byte_size
size_index=0
whilecurrent_size>=BASE_SIZEandlen(MEASURE) !=size_index:
current_size=current_size/BASE_SIZE
size_index=size_index+1
size=_fix_size(current_size, size_index)
measure=MEASURE[size_index]
returnsize+measure
Way

Bytes To Kilobytes Conversion (B To KB)

Bytes Conversion To Kb Downloadbackstage

Convert Bytes To Mb

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment