KBD

Keith Devens .com

Tuesday, October 14, 2008 Flag waving
... we can never use experience to prove the inductive principle without begging the question. Thus we must... forgo all justification... – Bertrand Russell ("On Induction" in The Problems of Philosophy)

Archive: June 04, 2007

← June 01, 2007June 06, 2007 →

Daily link icon Monday, June 4, 2007

How to "correctly" format currency in C#

For some reason C#, by default, formats negative currency as "($12,345,678.90)" instead of "-$12,345...". Here's code that lets you change that (wordwrapped for her pleasure):

// set currency format
string curCulture =
    System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
System.Globalization.NumberFormatInfo currencyFormat =
    new System.Globalization.CultureInfo(curCulture).NumberFormat;
currencyFormat.CurrencyNegativePattern = 1;

number.ToString("c", currencyFormat);
// or string.Format(currencyFormat, "{0:c}", number);

C# is retarded.

← June 01, 2007June 06, 2007 →
October 2008
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 6 posts

Recent comments XML

Spider solitaire

I have now won, at the "Difficult"​level, 186 games of Spider​Solitaire.  I...

75.179.28.113: Oct 13, 9:34am

Girls, please don't get breast implants

Please, don't marry him.

You​want to get surgery to make​yourself more i...

gigi: Oct 12, 11:47pm

I hate PHP

Elliot Anderson,

Dude!! You the​man! The reverse replacement for​array_u...

Alex Ndungu: Oct 11, 1:35am

Call a function from a string in Python

?!code:
some_object.__getattribute​__('method_name')()
?!/code

is​the s...

Patrick Corcoran: Oct 8, 3:53pm

Sed one-liners

Hi.

I wanted to let you know​that I wrote an article "Famous Sed​One-Lin...

Peteris Krumins: Oct 8, 3:05am

Generated in about 0.045s.

(Used 7 db queries)

mobile phone