Culture vulture
-
String amount = "123"; // added for clarity, horror follows
var actualAmount = Convert.ToDecimal(String.Format(CultureInfo.InvariantCulture ,"{0:N2}",
Convert.ToDecimal(amount, CultureInfo.InvariantCulture)),CultureInfo.InvariantCulture); -
String amount = "123"; // added for clarity, horror follows
var actualAmount = Convert.ToDecimal(String.Format(CultureInfo.InvariantCulture ,"{0:N2}",
Convert.ToDecimal(amount, CultureInfo.InvariantCulture)),CultureInfo.InvariantCulture);You've got more chance of peeing on JSOP's porch than you have of understanding why the developer did this.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
You've got more chance of peeing on JSOP's porch than you have of understanding why the developer did this.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
I think the developer was unhappy with the performance of Decimal.Round so decided to implement it using strings, as we know computers prefer working with text rather than numbers...
-
String amount = "123"; // added for clarity, horror follows
var actualAmount = Convert.ToDecimal(String.Format(CultureInfo.InvariantCulture ,"{0:N2}",
Convert.ToDecimal(amount, CultureInfo.InvariantCulture)),CultureInfo.InvariantCulture); -
I can sort of understand the point. It looks like it is trying to round the amount down to 2 decimal places. Odd way to go about it though. Reminds me of the old "man with a hammer" quote.
Unfortunately the original code monkey was using the hammer on his own skull.
Software Zen:
delete this;
-
I think the developer was unhappy with the performance of Decimal.Round so decided to implement it using strings, as we know computers prefer working with text rather than numbers...
Rounding is a hard, let's go shopping!