How to convert Kilobytes to Bytes?

Hi,

when issuing the “/system/resource/print” command via the API, I get the following information:

  Param 2: free-memory = 109252
  Param 3: total-memory = 127416
  ...
  Param 8: free-hdd-space = 483852
  Param 9: total-hdd-space = 520192

The same command run via SSH reveals that the numbers are kilobytes. Did you use 1000 (i.e. 10^3) or 1024 (i.e. 2^10) to convert from bytes to kilobytes?

Regards,
–octo

http://en.wikipedia.org/wiki/Data_rate_units

@ MT 10002 = megabyte

Hi again and thanks for the reply :slight_smile:

Sorry if I’m a bit dull-witted on the matter, but if I understand you correctly you’re saying one Megabyte equals 1000^2 (i.e. 1000 squared = one million) bytes? So 10^3 is used everywhere and 2^10 is never used?

(I’m a bit confused because the index-two is usually used to indicate a notation in base-two, i.e. 10002 = 810.)

Regards,
–octo

nop - my bad, it counts 1megabyte equal 1024kilobytes. And as we all know 1byte = 8bits

Thanks for the pointer, but unfortunately this doesn’t answer my question: Under GNU/Linux and many other operating systems, 2^10 is used as the factor between kilo, mega, giga, … when talking about memory (both, physical and virtual) but 10^3 is used when talking about disk space and traffic. This is due to the fact that memory is usually manufactured in powers of two, so a DRAM chip with, say, one gigabyte is actually larger, i.e. 2^30 bytes (one gibibyte).

Flash chips usually are organized in blocks that are a power of two in size, too. So assuming a physical size that’s a power of two here is reasonable, too. On the other hand, usually a percentage of those blocks is reserved for replacing bad blocks. Neither assuming 1000 nor 1024 gives me a power of two with >99% accuracy, so I thought I’d rather ask instead of assuming things.

Regards,
–octo

RouterOS reports memory and storage space in kilobytes, where 1Kbyte is 1024 bytes.

and in speeds, 1M=1000k=1000000 bits per second

Thanks, exactly what I needed to hear :slight_smile: I’ve updated librouteros to take this into account.

Regards,
—octo