This is a dumping ground of software development topics that I've run across and found interesting (mainly .NET development). Many topics are covered more thoroughly in other places, and much of the information is gleaned from other places, and I'll try to credit those sources when possible.

Friday, December 02, 2016

C# .NET: 
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