snippets / format

All snippets tagged format (2)

  1. Format decimal places

    .

     1 public static void generatoRandomDouble()
    2 {
    3 Random random = new Random();
    4 double r = random.NextDouble() * 100;
    5 // cut of all but 2 decimal places
    6 Console.WriteLine(r.ToString("#0.00"));
    7 // round the doube
    8 r= Math.Round(r, 2);
    9 Console.WriteLine(r);
    10 // use point "." as decimal point
    11 Console.WriteLine(r.ToString(CultureInfo.InvariantCulture.NumberFormat));
    12 }
    Posted by qrist0ph to c# format number ... saved by 1 person ... 0 comments ... 2 months
  2. [Win32] OutputDebugString with printf formating

    Use OutputDebugString with printf formating

     1 void DebugDisplayFmt( const char *str, ... ) 
    2 {
    3 char buf[2048];
    4
    5 va_list ptr;
    6 va_start(ptr,str);
    7 vsprintf(buf,str,ptr);
    8
    9 ::OutputDebugString( buf );
    10 }
    11
    12 //Use
    13 int value = 123;
    14 DebugDisplayFmt( "in %s(%d) : val = %d\n", __FILE__, __LINE__, value );
showing 10, 25, 50 items per pages

Pages : 1

Flux RSS friendsnippetLatest snippets


More...