Add operators for ByteSize and int & double (e.g. *, /, etc)
AdamCoulterOz opened this issue · comments
Support operators like the following:
ByteSize size = ByteSize.FromBytes(1000);
double pi = Math.PI;
ByteSize sizeTimesThree = size * 3;
ByteSize sizeDividedByPi = size / pi;
Just hit a case right after referencing the library for the first time, where I wanted to divide the total memory by "the number of threads" and noticed there is no division overload.
Would make my code simpler if it had it.
Having said that, I don't agree with having an overloaded ^
operator @AdamCoulterOz , since that's normally used for bitwise XOR. It would be extremely misleading to overload it to do something completely different.
Ha, I didn't realise c# didn't use ^
as an exponent operator. I completely agree in that case.
Added in 2.1.0
@omar this hasn't actually been implemented. I would expect to be able to divide or multiply ByteSize with a primitive number (i.e. int
or double
, etc).
I've just realised as well that the division operator should return a double
, not a ByteSize
, as it's now a ratio, not in units of bytes.