Because some people apparently think that gigabytes as a decimal is a good way to accurately store available storage space I now have the following code to convert it into a byte representation:
Convert.ToString(Convert.ToInt64(Math.Floor(someDecimal * 1024 * 1024)));
Now while this works (as-in returns the expected result), it’s not exactly elegant.
Is there a more elegant way to do this kind of conversion? (The floor is necessary).
Why don’t you just use this:
Of course, that should be encapsulated in some helper method. you don’t want that sprinkled throughout your code.