You're using the ^
operator, which is not an exponentiation operator. It's exclusive-OR.
Use Math.Pow
for exponentiation - or better, just use bit-shifting in this case:
long divided = bytes >> (n * 10);
return divided.ToString() + ...;
Alternatively, you could change your enum values to the actual values to divide by:
public enum ByteConversionConstant : long
{
B = 1L << 0,
KB = 1L << 10,
MB = 1L << 20,
GB = 1L << 30,
TB = 1L << 40,
PB = 1L << 50
}
Then:
long divided = n / (long) constant;