How many bytes per kilobyte (KB)? How many bytes per megabyte (MB)? How many bytes per terabyte (TB)? etc. I've used constants like these many times.

public static ulong BytesPerKilobyte = (ulong)Math.Pow(2.0, 10.0); // 1,024 public static ulong BytesPerMegabyte = (ulong)Math.Pow(2.0, 20.0); // 1,048,576 public static ulong BytesPerGigabyte = (ulong)Math.Pow(2.0, 30.0); // 1,073,741,824 public static ulong BytesPerTerabyte = (ulong)Math.Pow(2.0, 40.0); // 1,099,511,627,776

## No comments:

Post a Comment