index | submit | rank | book

kilobytes – Kilobytes

Write a program that computes how many bytes are there in given numbers of kilobytes (KB), megabytes (MB), gigabytes (GB), kibibytes (KiB), mebibytes (MiB) and gibibytes (GiB). Use the decimal scale (1000) for the kilo, mega and giga prefixes and the binary scale (1024) for the kibi, mebi and gibi prefixes.

Input and output

For each line of input there should be a number n and a unit u being either KB, MB, GB, KiB, MiB or GiB.

For each line of input there should be a line of output indicating how many bytes correspond to what was given on the input.

Input is given so that the resulting value n' is in the range 0 ≤ n' ≤ 1 073 741 824.

Example input

2 KB
2 KiB
12 MB
1 GiB

Example output

2000 bytes
2048 bytes
12000000 bytes
1073741824 bytes


try first: bytes2bits bits2bytes

try next: bconv

index | submit | rank | book

Copyright © 2020-2023 Rudy Matela
All rights reserved