public static double GetSizeDouble(this ByteType type, long size) { var bitDigits = 1.0d; if (type == ByteType.Auto) { if (size >= Long1024 * Long1024 * Long1024) { bitDigits = Long1024 * Long1024 * Long1024; } else if (size >= Long1024 * Long1024) { bitDigits = Long1024 * Long1024; } else if (size >= Long1024) { bitDigits = Long1024; } else { bitDigits = 1; } } else { bitDigits = type.ToBitDigits(); } return(size / bitDigits); }
public static long GetSize(this ByteType type, long size) { long bitDigits = 1; if (type == ByteType.Auto) { if (size >= Long1024 * Long1024 * Long1024) { bitDigits = Long1024 * Long1024 * Long1024; } else if (size >= Long1024 * Long1024) { bitDigits = Long1024 * Long1024; } else if (size >= Long1024) { bitDigits = Long1024; } else { bitDigits = 1; } } else { bitDigits = type.ToBitDigits(); } var remainder = (size % bitDigits) > 0 ? 1 : 0; return(size / bitDigits + remainder); }