We have a number that is in the form of gigabytes, terabytes or megabytes. We want to convert it to another unit scale. This can help with displaying high-level information.
using System;
class Program
{
static void Main()
{
Console.WriteLine(ConvertMegabytesToGigabytes(100000));
Console.WriteLine(ConvertMegabytesToTerabytes(100000));
Console.WriteLine(ConvertGigabytesToMegabytes(1));
Console.WriteLine(ConvertGigabytesToTerabytes(10000));
Console.WriteLine(ConvertTerabytesToMegabytes(1));
Console.WriteLine(ConvertTerabytesToGigabytes(10));
}
static double ConvertMegabytesToGigabytes(double megabytes)
// SMALLER
{
// 1024 megabyte in a gigabyte
return megabytes / 1024.0;
}
static double ConvertMegabytesToTerabytes(double megabytes)
// SMALLER
{
// 1024 * 1024 megabytes in a terabyte
return megabytes / (1024.0 * 1024.0);
}
static double ConvertGigabytesToMegabytes(double gigabytes)
// BIGGER
{
// 1024 gigabytes in a terabyte
return gigabytes * 1024.0;
}
static double ConvertGigabytesToTerabytes(double gigabytes)
// SMALLER
{
// 1024 gigabytes in a terabyte
return gigabytes / 1024.0;
}
static double ConvertTerabytesToMegabytes(double terabytes)
// BIGGER
{
// 1024 * 1024 megabytes in a terabyte
return terabytes * (1024.0 * 1024.0);
}
static double ConvertTerabytesToGigabytes(double terabytes)
// BIGGER
{
// 1024 gigabytes in a terabyte
return terabytes * 1024.0;
}
}
97.65625
0.095367431640625
1024
9.765625
1048576
10240